diff options
| -rw-r--r-- | lua.c | 3 | ||||
| -rw-r--r-- | testes/main.lua | 10 |
2 files changed, 8 insertions, 5 deletions
| @@ -302,7 +302,8 @@ static int collectargs (char **argv, int *first) { | |||
| 302 | case '-': /* '--' */ | 302 | case '-': /* '--' */ |
| 303 | if (argv[i][2] != '\0') /* extra characters after '--'? */ | 303 | if (argv[i][2] != '\0') /* extra characters after '--'? */ |
| 304 | return has_error; /* invalid option */ | 304 | return has_error; /* invalid option */ |
| 305 | *first = i + 1; | 305 | /* if there is a script name, it comes after '--' */ |
| 306 | *first = (argv[i + 1] != NULL) ? i + 1 : 0; | ||
| 306 | return args; | 307 | return args; |
| 307 | case '\0': /* '-' */ | 308 | case '\0': /* '-' */ |
| 308 | return args; /* script "name" is '-' */ | 309 | return args; /* script "name" is '-' */ |
diff --git a/testes/main.lua b/testes/main.lua index cec4fa04..ff408f13 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 |
| @@ -346,7 +346,7 @@ RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out) | |||
| 346 | checkprogout("6\n10\n10\n\n") | 346 | checkprogout("6\n10\n10\n\n") |
| 347 | 347 | ||
| 348 | prepfile("a = [[b\nc\nd\ne]]\n=a") | 348 | prepfile("a = [[b\nc\nd\ne]]\n=a") |
| 349 | RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out) | 349 | RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i -- < %s > %s]], prog, out) |
| 350 | checkprogout("b\nc\nd\ne\n\n") | 350 | checkprogout("b\nc\nd\ne\n\n") |
| 351 | 351 | ||
| 352 | -- input interrupted in continuation line | 352 | -- input interrupted in continuation line |
| @@ -478,12 +478,14 @@ assert(not os.remove(out)) | |||
| 478 | -- invalid options | 478 | -- invalid options |
| 479 | NoRun("unrecognized option '-h'", "lua -h") | 479 | NoRun("unrecognized option '-h'", "lua -h") |
| 480 | NoRun("unrecognized option '---'", "lua ---") | 480 | NoRun("unrecognized option '---'", "lua ---") |
| 481 | NoRun("unrecognized option '-Ex'", "lua -Ex") | 481 | NoRun("unrecognized option '-Ex'", "lua -Ex --") |
| 482 | NoRun("unrecognized option '-vv'", "lua -vv") | 482 | NoRun("unrecognized option '-vv'", "lua -vv") |
| 483 | NoRun("unrecognized option '-iv'", "lua -iv") | 483 | NoRun("unrecognized option '-iv'", "lua -iv") |
| 484 | NoRun("'-e' needs argument", "lua -e") | 484 | NoRun("'-e' needs argument", "lua -e") |
| 485 | NoRun("syntax error", "lua -e a") | 485 | NoRun("syntax error", "lua -e a") |
| 486 | NoRun("'-l' needs argument", "lua -l") | 486 | NoRun("'-l' needs argument", "lua -l") |
| 487 | NoRun("-i", "lua -- -i") -- handles -i as a script name | ||
| 488 | |||
| 487 | 489 | ||
| 488 | 490 | ||
| 489 | if T then -- test library? | 491 | if T then -- test library? |
