Erlang/OTP Forums

Author Message

<  Erlang bugs mailing list  ~  arguments after --

ulf.wiger at ericsson.com
Posted: Wed Aug 31, 2005 12:27 pm Reply with quote
Guest
Snipped from the 'erl' documentation:

"--
Any arguments following -- will not be interpreted in any way.
They can be retrieved by init:get_plain_arguments/0.
The exception is arguments starting with a +, which will be
interpreted as system flags (see below). "

but some experimentation shows that it doesn't work as advertised:

$ erl -boot start_clean -sname foo
Erlang (BEAM) emulator version 5.4.7 [hipe] [threads:0] [kernel-poll]

Eshell V5.4.7 (abort with ^G)
(foo_at_ws12858)1> application:get_env(kernel,net_ticktime).
undefined
(foo_at_ws12858)2>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
a
$ erl -boot start_clean -sname foo -kernel net_ticktime 60
Erlang (BEAM) emulator version 5.4.7 [hipe] [threads:0] [kernel-poll]

Eshell V5.4.7 (abort with ^G)
(foo_at_ws12858)1> application:get_env(kernel,net_ticktime).
{ok,60}
(foo_at_ws12858)2>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
a
$ erl -boot start_clean -sname foo -- -kernel net_ticktime 60
Erlang (BEAM) emulator version 5.4.7 [hipe] [threads:0] [kernel-poll]

Eshell V5.4.7 (abort with ^G)
(foo_at_ws12858)1> application:get_env(kernel,net_ticktime).
{ok,60}
(foo_at_ws12858)2> init:get_plain_arguments().
[]
(foo_at_ws12858)3>


My conclusion was that erlexec uses "--" to separate the
automatically generated options from the user options.
But all these options end up in init:get_arguments() anyway,
so I'm unsure as to what it accomplishes.

There is also an "-extra" option, which is supposed to do
exactly the same thing as "--" is supposed to do. "-extra"
_does_ work exactly as advertised.


The included patches suggest a way to address the problem.

First, change erlexec.c so that it doesn't overload "--":

*** /home/etxuwig/OSE/tmp/otp_src_R10B-7/erts/etc/common/erlexec.c Tue Mar 22 15:09:54 2005
--- erlexec.c Wed Aug 31 14:04:11 2005
***************
*** 675,681 ****
add_Eargs(rootdir);
add_Eargs("-progname");
add_Eargs(progname);
! add_Eargs("--");
ensure_EargsSz(EargsCnt + argsCnt + 1);
for (i = 0; i < argsCnt; i++)
Eargsp[EargsCnt++] = argsp[i];
--- 675,681 ----
add_Eargs(rootdir);
add_Eargs("-progname");
add_Eargs(progname);
! add_Eargs("-end");
ensure_EargsSz(EargsCnt + argsCnt + 1);
for (i = 0; i < argsCnt; i++)
Eargsp[EargsCnt++] = argsp[i];

Then, change init.erl, so that it recognizes "-end":

ws12858> gdiff -c ~/OSE/tmp/otp_src_R10B-7/lib/kernel/src/init.erl init.erl
*** /home/etxuwig/OSE/tmp/otp_src_R10B-7/lib/kernel/src/init.erl Tue May 10 17:08:13 2005
--- init.erl Wed Aug 31 14:06:46 2005
***************
*** 1055,1061 ****
check(<<"-s">>) -> start_arg;
check(<<"-run">>) -> start_arg2;
check(<<"-eval">>) -> eval_arg;
! check(<<"--">>) -> end_args;
check(X) when binary(X) ->
case binary_to_list(X) of
[$-|_Rest] -> flag;
--- 1055,1062 ----
check(<<"-s">>) -> start_arg;
check(<<"-run">>) -> start_arg2;
check(<<"-eval">>) -> eval_arg;
! check(<<"-end">>) -> end_args;
! check(<<"--">>) -> start_extra_arg;
check(X) when binary(X) ->
case binary_to_list(X) of
[$-|_Rest] -> flag;


/Uffe


Post generated using Mail2Forum (http://m2f.sourceforge.net)

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum