[erlang-bugs] lost quotes in port arguments on Windows

Lukas Larsson lukas@REDACTED
Tue Apr 8 17:50:04 CEST 2014


Hello,

Thanks for the bug report. Apparently there is some special code in the 
spawn_executable parts that mess things up by trying to be smart. Using 
spawn and handling the quoting yourself seems work better.

I've written a patch for spawn_executable that fixes your problem, 
hopefully the tests will tell if I've managed to break something that 
depended on the current behaviour.

Lukas
On 07/04/14 23:28, Aliaksey Artamonau wrote:
> Hi all,
>
> We've recently encountered a problem with application arguments being 
> interpreted differently on Windows and on GNU/Linux. Basically if we 
> pass something like "\"path\"" to our application, it's then correctly 
> returned as string by application:get_env/2 function on GNU/Linux. On 
> Windows though, it's being interpreted as an atom. Which causes 
> problems if path happens to contain something that can't be part of 
> unquoted atom (like colon character). After some investigation, I've 
> come up with the following code snippet to demonstrate the root cause 
> of our problem:
>
> (fun () ->
>          P = open_port({spawn_executable, os:find_executable("erl")},
>                        [exit_status,
>                         {line, 2000},
>                         {args, ["-noshell", "-noinput",
>                                 "-app", "test", "arg with\"\"double 
> quotes in it",
>                                 "-eval", "io:format([126,112,126,110], 
> [init:get_argument(app)]), erlang:halt(0)."]}]),
>
>          F = fun (R) ->
>                      receive
>                          {P, {data, {_, L}}} -> io:format("~s~n", 
> [L]), R(R);
>                          {P, {exit_status, _}} -> ok
>                      end
>              end,
>          F(F)
>  end)().
>
>
> I just paste it into erl shell. If I run this on GNU/Linux with 
> R16B03-1, I get this:
>
> {ok,[["test","arg with\"\"double quotes in it"]]}
> ok
>
>
> On Windows with the same Erlang version I get this:
>
> {ok,[["test","arg with\"double quotes in it"]]}
> ok
>
> Note that one of the quotes disappeared from the argument.
>
>
> Best regards,
> Aliaksey.
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
>




More information about the erlang-bugs mailing list