-
-
Save dch/4189389ecd2bf1ca8163 to your computer and use it in GitHub Desktop.
fix-escript-vm-args-win32-shebang-parsing.escript.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git i/erts/doc/src/escript.xml w/erts/doc/src/escript.xml | |
index 66e904f..e829d5b 100644 | |
--- i/erts/doc/src/escript.xml | |
+++ w/erts/doc/src/escript.xml | |
@@ -74,8 +74,10 @@ $ <input>factorial five</input> | |
usage: factorial integer </pre> | |
<p>The header of the Erlang script in the example differs from | |
a normal Erlang module. The first line is intended to be the | |
- interpreter line, which invokes <c>escript</c>. However if you | |
- invoke the <c>escript</c> like this</p> | |
+ interpreter line, which invokes <c>escript</c>. Subsequent parsing | |
+ of emulator arguments is only done if the interpreter line matches | |
+ <c>#!</c> or <c>@</c>, supporting Unix-like platforms and Windows | |
+ respectively. However if you invoke the <c>escript</c> like this</p> | |
<pre> | |
$ <input>escript factorial 5</input> </pre> | |
<p>the contents of the first line does not matter, but it | |
@@ -91,7 +93,7 @@ $ <input>escript factorial 5</input> </pre> | |
<pre> | |
%%! -smp enable -sname factorial -mnesia debug verbose</pre> | |
<p>Such an argument line must start with <c>%%!</c> and the | |
- rest of the line will interpreted as arguments to the emulator.</p> | |
+ rest of the line will be interpreted as arguments to the emulator.</p> | |
<p>If you know the location of the <c>escript</c> executable, the first | |
line can directly give the path to <c>escript</c>. For instance:</p> | |
<pre> | |
diff --git i/erts/etc/common/escript.c w/erts/etc/common/escript.c | |
index 9e80ec6..dcb1c85 100644 | |
--- i/erts/etc/common/escript.c | |
+++ w/erts/etc/common/escript.c | |
@@ -264,7 +264,8 @@ append_shebang_args(char* scriptname) | |
static char linebuf[LINEBUFSZ]; | |
char* ptr = fgets(linebuf, LINEBUFSZ, fd); | |
- if (ptr != NULL && linebuf[0] == '#' && linebuf[1] == '!') { | |
+ /* Acceptable Shebang syntax is #/ for unix or @ for windows */ | |
+ if (ptr != NULL && ((linebuf[0] == '#' && linebuf[1] == '!') || linebuf[0] == '@')) { | |
/* Try to find args on second or third line */ | |
ptr = fgets(linebuf, LINEBUFSZ, fd); | |
if (ptr != NULL && linebuf[0] == '%' && linebuf[1] == '%' && linebuf[2] == '!') { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment