in reply to Re^7: quoting issue with system command (Win32)
in thread quoting issue with system command

No, it works when you do it right (don't specify the quotes).

So, how would you do it "right" if you need to pass a value that is double-quoted, using the multi-argument form?  I.e., if you want the called program to get a value like '"some value"' (including the double quotes) as one argument.

(Hmm, seems the content of the node changed while I was replying...)

Replies are listed 'Best First'.
Re^9: quoting issue with system command (Win32)
by ikegami (Patriarch) on May 13, 2009 at 16:21 UTC
    Sorry, I wasn't sure what I was trying to say.

    if you want the called program to get a value like '"some value"' (including the double quotes) as one argument.

    I don't know if there's a standard quoting rule for that. If there is, then you're right, it's buggy. (Perhaps intentionally for backwards compatibility reasons?)

Re^9: quoting issue with system command (Win32)
by John M. Dlugosz (Monsignor) on May 13, 2009 at 20:54 UTC
    Easy: forget the non-portable and provincial system function and call the platform-specific CreateProcess in the Win32 API, passing it the string you really intend.

      I respectfully disagree. Isn't the basic problem on Windows that the Windows API (i.e. CreateProcess) does simply not allow for several individual command line arguments to be passed to a program (as it is possible on Unix)?  All that CreateProcess allows to be specified is a single string (lpCommandLine) — so I don't really see any advantage of using CreateProcess with respect to quoting issues, compared to using system().

      If there was any way to properly emulate Unix semantics (i.e. separate arguments) on Windows to get around quoting issues etc., I'm pretty sure the Makers of Perl would have utilized that possibility...

        Because the problem is that the auto-munging system function won't give the desired string. If it has quotes, it leaves them, rather than adding another. Hmm, I guess adding two sets would work. No, how are the inner ones escaped? Owell. Why's it so hard to make it come up with the string I wanted?

        So stop asking it, and just use the string you wanted.

        His question concerns a Windows program. If the basic problem is that Windows is not the same as Unix, that doesn't help.

        —John