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

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.

Replies are listed 'Best First'.
Re^10: quoting issue with system command (Win32)
by almut (Canon) on May 13, 2009 at 21:41 UTC

    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