aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua.c3
-rw-r--r--testes/main.lua9
2 files changed, 7 insertions, 5 deletions
diff --git a/lua.c b/lua.c
index a90bf29b..66fb74b7 100644
--- a/lua.c
+++ b/lua.c
@@ -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[[
901, a 901, a
91) 91)
92]] 92]]
93RUN('lua - < %s > %s', prog, out) 93RUN('lua - -- < %s > %s', prog, out)
94checkout("1\tnil\n") 94checkout("1\tnil\n")
95 95
96RUN('echo "print(10)\nprint(2)\n" | lua > %s', out) 96RUN('echo "print(10)\nprint(2)\n" | lua > %s', out)
@@ -133,7 +133,7 @@ checkout("-h\n")
133prepfile("print(package.path)") 133prepfile("print(package.path)")
134 134
135-- test LUA_PATH 135-- test LUA_PATH
136RUN('env LUA_INIT= LUA_PATH=x lua %s > %s', prog, out) 136RUN('env LUA_INIT= LUA_PATH=x lua -- %s > %s', prog, out)
137checkout("x\n") 137checkout("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)
358checkprogout("6\n10\n10\n\n") 358checkprogout("6\n10\n10\n\n")
359 359
360prepfile("a = [[b\nc\nd\ne]]\na") 360prepfile("a = [[b\nc\nd\ne]]\na")
361RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out) 361RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i -- < %s > %s]], prog, out)
362checkprogout("b\nc\nd\ne\n\n") 362checkprogout("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
489NoRun("unrecognized option '-h'", "lua -h") 489NoRun("unrecognized option '-h'", "lua -h")
490NoRun("unrecognized option '---'", "lua ---") 490NoRun("unrecognized option '---'", "lua ---")
491NoRun("unrecognized option '-Ex'", "lua -Ex") 491NoRun("unrecognized option '-Ex'", "lua -Ex --")
492NoRun("unrecognized option '-vv'", "lua -vv") 492NoRun("unrecognized option '-vv'", "lua -vv")
493NoRun("unrecognized option '-iv'", "lua -iv") 493NoRun("unrecognized option '-iv'", "lua -iv")
494NoRun("'-e' needs argument", "lua -e") 494NoRun("'-e' needs argument", "lua -e")
495NoRun("syntax error", "lua -e a") 495NoRun("syntax error", "lua -e a")
496NoRun("'-l' needs argument", "lua -l") 496NoRun("'-l' needs argument", "lua -l")
497NoRun("-i", "lua -- -i") -- handles -i as a script name
497 498
498 499
499if T then -- test library? 500if T then -- test library?