-
-
Save robertoaloi/1184144 to your computer and use it in GitHub Desktop.
#!/bin/sh | |
CMD="erl -noinput -eval 'erlang:display({foo, bar}).' -s init stop" | |
echo "Exec: $CMD" | |
exec $CMD |
The printout is mangled: [>,>]
cannot be the real Erlang term here. I think that something causes the argument to -init to be expanded to two separate words by the Mac shell. For example, this reproduces the error on my Linux laptop:
erl -noinput -eval one two -s init stop
(no error logger present) error: "Error in process <0.0.0> with exit value: {function_clause [{init,prepare_run_args,[{eval,[<<3 bytes>>,<<3 bytes>>]}]},{init,map,2},{init,boot,1}]}
(You can see in the Mac printout that the <0.0.0> is also missing - there's two spaces between "process" and "with".)
The output has been modified when copying it in the gist. It looks all right in the shell.
The same thing happened to my comment above (updated now). I had forgotten to markdownify it properly.
Anyway, shell expansion is the problem. The same happens on Linux. When you wrap the CMD text in double quotes, you apparently prevent the single quotes from being considered as quotes in the $CMD expansion, so you effectively get the following:
exec "erl" "-noinput" "-eval" "'erlang:display({foo," "bar}).'" "-s" "init" "stop"
Revision #39603b will output the following error: