escript, flags to script

Thierry Mallard thierry.mallard@REDACTED
Fri Mar 23 17:32:26 CET 2001


On Fri, Mar 23, 2001 at 04:43:54PM +0100, Thierry Mallard wrote:
> I think there is a bug in the parsing of the arguments. Not looked at the
> sources yet, but it seems that if there is a "-" in an argument, [] is passed
> instead [...]
> Still have to find out why...

Ok, I did some quick work with the help of Mickael Remond.

Here is the patch : we now parses the arguments, that are grouped in the shell
using " ... "

Hope this helps.

	Best regards,

-- 
Thierry Mallard              | http://vawis.net
GnuPG key on wwwkeys.pgp.net | http://erlang-fr.org (new)
key 0xA3D021CB               | http://worldforge.org
-------------- next part --------------
diff -urN escript-1.0/escript.erl escript-1.0.1/escript.erl
--- escript-1.0/escript.erl	Fri Mar 23 14:58:01 2001
+++ escript-1.0.1/escript.erl	Fri Mar 23 17:19:10 2001
@@ -12,8 +12,10 @@
 -import(lists, [map/2, member/2]).
 
 go(X0) ->
-    X = map(fun(I) -> atom_to_list(I) end, X0),
-    [_,F|Args] = X,
+    [X] = map(fun(I) -> atom_to_list(I) end, X0),
+    T = string:tokens(X, " "),   %% We separated into strings
+    [_|FArgs] = T,  %% We drop the program path
+    [F|Args] = FArgs,   %% Separata into script file path and args
     %% io:format("Escript:~p~n",[X]),
     {Nerrs, Dict} = parse_file(F),
     if
diff -urN escript-1.0/mk_escript.sh escript-1.0.1/mk_escript.sh
--- escript-1.0/mk_escript.sh	Fri Mar 23 14:58:01 2001
+++ escript-1.0.1/mk_escript.sh	Fri Mar 23 17:25:26 2001
@@ -2,6 +2,6 @@
 CWD=`pwd`
 echo $CWD
 echo "#!/bin/sh" > escript
-echo "erl -pa $CWD -noshell -s escript go \$0 \$*" >> escript
+echo "erl -pa $CWD -noshell -s escript go \"\$0 \$*\"" >> escript
 chmod u+x escript
 


More information about the erlang-questions mailing list