diff options
-rw-r--r-- | lua.c | 3 | ||||
-rw-r--r-- | testes/main.lua | 9 |
2 files changed, 7 insertions, 5 deletions
@@ -303,7 +303,8 @@ static int collectargs (char **argv, int *first) { | |||
303 | case '-': /* '--' */ | 303 | case '-': /* '--' */ |
304 | if (argv[i][2] != '\0') /* extra characters after '--'? */ | 304 | if (argv[i][2] != '\0') /* extra characters after '--'? */ |
305 | return has_error; /* invalid option */ | 305 | return has_error; /* invalid option */ |
306 | *first = i + 1; | 306 | /* if there is a script name, it comes after '--' */ |
307 | *first = (argv[i + 1] != NULL) ? i + 1 : 0; | ||
307 | return args; | 308 | return args; |
308 | case '\0': /* '-' */ | 309 | case '\0': /* '-' */ |
309 | return args; /* script "name" is '-' */ | 310 | return args; /* script "name" is '-' */ |
diff --git a/testes/main.lua b/testes/main.lua index eb63d588..dc48dc48 100644 --- a/testes/main.lua +++ b/testes/main.lua | |||
@@ -90,7 +90,7 @@ prepfile[[ | |||
90 | 1, a | 90 | 1, a |
91 | ) | 91 | ) |
92 | ]] | 92 | ]] |
93 | RUN('lua - < %s > %s', prog, out) | 93 | RUN('lua - -- < %s > %s', prog, out) |
94 | checkout("1\tnil\n") | 94 | checkout("1\tnil\n") |
95 | 95 | ||
96 | RUN('echo "print(10)\nprint(2)\n" | lua > %s', out) | 96 | RUN('echo "print(10)\nprint(2)\n" | lua > %s', out) |
@@ -133,7 +133,7 @@ checkout("-h\n") | |||
133 | prepfile("print(package.path)") | 133 | prepfile("print(package.path)") |
134 | 134 | ||
135 | -- test LUA_PATH | 135 | -- test LUA_PATH |
136 | RUN('env LUA_INIT= LUA_PATH=x lua %s > %s', prog, out) | 136 | RUN('env LUA_INIT= LUA_PATH=x lua -- %s > %s', prog, out) |
137 | checkout("x\n") | 137 | checkout("x\n") |
138 | 138 | ||
139 | -- test LUA_PATH_version | 139 | -- test LUA_PATH_version |
@@ -358,7 +358,7 @@ RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out) | |||
358 | checkprogout("6\n10\n10\n\n") | 358 | checkprogout("6\n10\n10\n\n") |
359 | 359 | ||
360 | prepfile("a = [[b\nc\nd\ne]]\na") | 360 | prepfile("a = [[b\nc\nd\ne]]\na") |
361 | RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out) | 361 | RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i -- < %s > %s]], prog, out) |
362 | checkprogout("b\nc\nd\ne\n\n") | 362 | checkprogout("b\nc\nd\ne\n\n") |
363 | 363 | ||
364 | -- input interrupted in continuation line | 364 | -- input interrupted in continuation line |
@@ -488,12 +488,13 @@ assert(not os.remove(out)) | |||
488 | -- invalid options | 488 | -- invalid options |
489 | NoRun("unrecognized option '-h'", "lua -h") | 489 | NoRun("unrecognized option '-h'", "lua -h") |
490 | NoRun("unrecognized option '---'", "lua ---") | 490 | NoRun("unrecognized option '---'", "lua ---") |
491 | NoRun("unrecognized option '-Ex'", "lua -Ex") | 491 | NoRun("unrecognized option '-Ex'", "lua -Ex --") |
492 | NoRun("unrecognized option '-vv'", "lua -vv") | 492 | NoRun("unrecognized option '-vv'", "lua -vv") |
493 | NoRun("unrecognized option '-iv'", "lua -iv") | 493 | NoRun("unrecognized option '-iv'", "lua -iv") |
494 | NoRun("'-e' needs argument", "lua -e") | 494 | NoRun("'-e' needs argument", "lua -e") |
495 | NoRun("syntax error", "lua -e a") | 495 | NoRun("syntax error", "lua -e a") |
496 | NoRun("'-l' needs argument", "lua -l") | 496 | NoRun("'-l' needs argument", "lua -l") |
497 | NoRun("-i", "lua -- -i") -- handles -i as a script name | ||
497 | 498 | ||
498 | 499 | ||
499 | if T then -- test library? | 500 | if T then -- test library? |