saleyn / erlexec

Execute and control OS processes from Erlang/OTP
https://hexdocs.pm/erlexec/readme.html
Other
541 stars 141 forks source link

Zero length arguments considered invalid #81

Closed gar1t closed 8 years ago

gar1t commented 8 years ago
> exec:run(["/bin/echo", ""], [sync, stdout]).
{error,"badarg: invalid command argument #1"}

Looking at ei++.hpp decodeString the change wasn't obvious to me.

saleyn commented 8 years ago

Why are you using this syntax as opposed to any one of the following?

2> exec:run("/bin/echo", [sync, stdout]).
{ok,[{stdout,[<<"\n">>]}]}
3> exec:run(["/bin/echo"], [sync, stdout]).
{ok,[{stdout,[<<"\n">>]}]}
gar1t commented 8 years ago

This is just an example to highlight the behavior - my goal here isn't to echo chars :)

A zero length argument is a valid argument and this behavior prohibits their use.

gar1t commented 8 years ago

It's admittedly not a common case, but there are times when you may want to indicate that a particular argument exists positionally but is empty.

saleyn commented 8 years ago

I pushed the fix that takes care of it.

gar1t commented 8 years ago

Terrific - thanks!