[erlang-questions] os:cmd string parsing bug on Windows's erl

Erik Søe Sørensen eriksoe@REDACTED
Fri Jun 27 11:54:01 CEST 2014


While on the topic, could we please have an "cmd()" which takes a program
name and a list of parameters, instead of just a string?
That would be less prone to both whitespace errors and injection issues.
Using os:cmd() with anything but a fixed string always gives me an uneasy
feeling:

15> Echo = fun(Text) -> os:cmd("echo "++Text) end.
#Fun<erl_eval.6.106461118>
16> Echo("Hello!").
"Hello!\n"
17> Echo("; date").
"\nfre jun 27 11:51:07 CEST 2014\n"

(On the other hand, I'm glad that open_port() *does* support the program
name + argument list mode.)


2014-06-27 10:29 GMT+02:00 Lukas Larsson <lukas@REDACTED>:

> Hello,
>
> On Fri, Jun 27, 2014 at 3:39 AM, KukHyun Lee <kukhyun@REDACTED> wrote:
>
>> Hello,
>>
>> erl on Windows7, os:cmd doesn't parse 'white-space'.
>>
>> C:\>erl
>> Eshell V6.0  (abort with ^G)
>> 1> os:cmd("c:/Program Files/test.exe").
>> 'c:/Program' is not recognized as an internal or external command,
>> operable program or batch file.
>> []
>>
>>
> Thanks for reporting this bug! I believe that I have fixed it already.
> Unfortunately the fix introduces a backwards incompatibility so it will not
> be released until OTP 18.  The fix is already merged into the master branch
> at github.
>
> Lukas
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140627/eb29d46f/attachment.htm>


More information about the erlang-questions mailing list