lua option '--' may not be followed by script

This commit is contained in:
Roberto Ierusalimschy
2025-07-08 15:40:59 -03:00
parent 942c10a5e3
commit f65d1f9e02
2 changed files with 7 additions and 5 deletions

3
lua.c
View File

@@ -303,7 +303,8 @@ static int collectargs (char **argv, int *first) {
case '-': /* '--' */
if (argv[i][2] != '\0') /* extra characters after '--'? */
return has_error; /* invalid option */
*first = i + 1;
/* if there is a script name, it comes after '--' */
*first = (argv[i + 1] != NULL) ? i + 1 : 0;
return args;
case '\0': /* '-' */
return args; /* script "name" is '-' */