Passing command line options to erlang programs

Muharem Hrnjadovic muharem@REDACTED
Tue Oct 26 07:43:26 CEST 2010


Hello,

I am fairly new to erlang, so please forgive me if this is a stupid
question :-)

I am trying to pass command line options to the following erlang program:
{{{
-module(demo).
-export([main/1]).

main(Args) -> io:format("~p~n", [Args]).
}}}

When only passing command line *arguments* everything works as expected:

{{{
$ erl -noshell -s demo main a b c -s init stop
[a,b,c]
}}}

But when passing command line *options* things break

{{{
$ erl -noshell -s demo main a -b c -s init stop
[a]
$ erl -noshell -s demo main -a b c -s init stop
{"init terminating in
do_boot",{undef,[{demo,main,[]},{init,start_it,1},{init,start_em,1}]}}

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
}}}

Is there another way to sneak options past erl? Or is the code above
broken in some other way?
If no, then maybe erl needs an option passing/escape mechanism like e.g.
gcc's "-Wl" ..?

When using an escript file BTW things works as one would expect.

Best regards/Mit freundlichen Grüßen

-- 
Muharem Hrnjadovic <muharem@REDACTED>
Public key id   : B2BBFCFC
Key fingerprint : A5A3 CC67 2B87 D641 103F  5602 219F 6B60 B2BB FCFC



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20101026/d9158c70/attachment.bin>


More information about the erlang-questions mailing list