pipeProcess failing

Paul Backus snarwin at gmail.com
Sun Jun 3 15:59:04 UTC 2018


On Sunday, 3 June 2018 at 15:07:07 UTC, DigitalDesigns wrote:
> I'm calling pipe process using
>
> pipeProcess([AliasSeq!args], Redirect.stdout | Redirect.stdin);
>
> where args is a tuple.
>
>
> Everything works when I pass each argument individually. If I 
> combine any args using a space it fails or if I pass an 
> argument with "".
>
> So I guess something like this
>
> pipeProcess(["dmd", "", "-m32 -JC:\"], Redirect.stdout | 
> Redirect.stdin);
>
> will fail while
>
> pipeProcess(["dmd", "-m32", "-JC:\"], Redirect.stdout | 
> Redirect.stdin);
>
> works.
>
> Is this a bug or something else going on I'm not aware of?
>
> I'm just wrapping pipe process in a function foo(Args...)(Args 
> args) and calling it like foo("dmd", "", "-m32 -JC:\").
>
> The reason why it is a problem is that it will simplify some 
> code to be able to combine some arguments.

The argument list is just passed along to the child process as 
its argv. So if the child process is able to handle empty strings 
or space-combined arguments in argv, then it will work, and if 
the child process can't do that, it will fail.

Normally, the command-line shell takes care of splitting 
arguments into separate strings, and never passes empty 
arguments, so most programs are not prepared to handle those 
cases. If you want the shell to do this work for you, you can try 
using pipeShell instead of pipeProcess. Otherwise, you will have 
to do it yourself.


More information about the Digitalmars-d-learn mailing list