diff options
Diffstat (limited to 'system/dash/posix-dashes.patch')
-rw-r--r-- | system/dash/posix-dashes.patch | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/system/dash/posix-dashes.patch b/system/dash/posix-dashes.patch new file mode 100644 index 000000000..b852ec20c --- /dev/null +++ b/system/dash/posix-dashes.patch @@ -0,0 +1,87 @@ +From 54485578e01017534dae30731f7682abadb38a09 Mon Sep 17 00:00:00 2001 +From: наб <nabijaczleweli@nabijaczleweli.xyz> +Date: Wed, 4 Jan 2023 12:33:45 +0100 +Subject: builtin: Ignore first -- in getopts per POSIX +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Issue 7, XCU, getopts, OPTIONS reads "None.", +and getopts isn't a special built-in listed in sexion 2.14 ‒ +this means that XCU, 1. Introduction, 1.4 Utility Description Defaults, +OPTIONS, Default Behavior applies: + Default Behavior: When this section is listed as "None.", it means + that the implementation need not support any options. Standard + utilities that do not accept options, but that do accept operands, + shall recognize "--" as a first argument to be discarded. + +Test with: getopts -- d: a +Correct output is no output, exit 1 +Wrong output errors out with d: being an invalid argument name + +Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> +--- + src/options.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/options.c b/src/options.c +index 3158498..2d4bd3b 100644 +--- a/src/options.c ++++ b/src/options.c +@@ -409,6 +409,9 @@ getoptscmd(int argc, char **argv) + { + char **optbase; + ++ nextopt(nullstr); ++ argc -= argptr - argv - 1; ++ argv = argptr - 1; + if (argc < 3) + sh_error("Usage: getopts optstring var [arg...]"); + else if (argc == 3) { +-- +cgit + +From ba57b84b305dd16f9d3e0d798835a7e9e15454ae Mon Sep 17 00:00:00 2001 +From: наб <nabijaczleweli@nabijaczleweli.xyz> +Date: Wed, 4 Jan 2023 12:35:13 +0100 +Subject: builtin: Ignore first -- in type for consistency +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This appears to be the only remaining built-in that doesn't use +nextopt() to parse its arguments (and isn't forbidden from doing so) ‒ +users expect to be able to do this, and it's nice to be consistent here. + +Test with: type -- ls -- +Correct output lists ls=/bin/ls, then --=ENOENT +Wrong output lists --=ENOENT, ls=/bin/ls, --=ENOENT + +Fixes: https://bugs.debian.org/870317 +Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> +--- + src/exec.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/exec.c b/src/exec.c +index d7a1f53..83cba94 100644 +--- a/src/exec.c ++++ b/src/exec.c +@@ -766,11 +766,11 @@ unsetfunc(const char *name) + int + typecmd(int argc, char **argv) + { +- int i; + int err = 0; + +- for (i = 1; i < argc; i++) { +- err |= describe_command(out1, argv[i], NULL, 1); ++ nextopt(nullstr); ++ while (*argptr) { ++ err |= describe_command(out1, *argptr++, NULL, 1); + } + return err; + } +-- +cgit + |