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

Aliaksey Artamonau <>
Mon Apr 7 23:28:18 CEST 2014


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.


More information about the erlang-bugs mailing list