Euphoria Ticket #547: system_exec() should accept spaces

It does not, not sure why.

talks about using quoted strings as normal for parameters sent to spawn* functions.


Type: Feature Request Severity: Normal Category: Library Routine
Assigned To: unknown Status: New Reported Release: 4686
Fixed in SVN #: View VCS: none Milestone:

1. Comment by jimcbrown Dec 17, 2010

I don't know if that is so easy. The problem is that Windows programs get the entire command line as a single string, either from GetCommandLine() or passed in the call to WinMain().

spawn() has to be a wrapper around CreateProcess() at some level. And CreateProcess() only accepts a single big string.

The easiest way to fix this might be to call C's system() for Euphoria's system_exec() on WIndows, the same as we already do for Unix. This will make system_exec() do the right thing if system() already does the right thing.

Speaking of which, a peeve I have is that the current options in the stdlib to start a program (system(), system_exec(), pipeio:create() / pipeio:exec() ) all require passing a string. Unix allows one to specify the argv directly and pass that to the child process, with no shell globbing or quoting getting in the way. Why don't we have a function to do that?

2. Comment by SDPringle Nov 22, 2011

Remember we have build_commandline() to bridge the gap between UNIX style string array exec() to Windows single string with spaces. Clearly system_exec() accepts spaces to separate arguments. Did Jeremy mean spaces in the the program's path?

3. Comment by jimcbrown Nov 22, 2011

I think I wrote that before we had build_commandline(). Anyways, that's not good enough for me.

By directly calling execvp(), you can do weird things like pass in a fake program name to the program being run.

Jeremy's original request was to be able to use spaces in quoted strings as parameters. e.g.

run.exe "This is one param" "This is param two" and_three "and so on" 

4. Comment by SDPringle Nov 22, 2011

In UNIX you can do this by using EUPHORIA's C interface. It seems it would be neither commonly used nor could it be simulated well under Windows via build_commandline() in all cases.

5. Comment by jimcbrown Nov 23, 2011

Oll Korrect. You have to wrap it yourself though, but the point that this might be so rarely used that it's not worth wrapping and adding to the stdlib is a point worth .. er ..


Quick Links

User menu

Not signed in.

Misc Menu