Skip to content
Snippets Groups Projects
Commit 81a501b7 authored by Martijn Dekker's avatar Martijn Dekker Committed by Herbert Xu
Browse files

expand: 'nolog' and 'debug' options cause "$-" to wreak havoc


Op 29-03-17 om 20:02 schreef Martijn Dekker:
> Bug: if either the 'nolog' or the 'debug' option is set, trying to
> expand "$-" silently aborts parsing of an entire argument.
>
> $ dash -o nolog -c 'set -fuC; echo "|$- are the options|"; \
> 	set +o nolog; echo "|$- are the options|"'
> |
> |uCf are the options|
> $ dash -o debug -c 'set -fuC; echo "|$- are the options|"; \
> 	set +o debug; echo "|$- are the options|"'
> |
> |uCf are the options|

This turned out to be easy to fix. The routine producing the "$-"
expansion failed to skip options for which there is no option letter,
but only a long-form name. In dash, 'nolog' and 'debug' are currently
the only two such options. Patch below.

- Martijn

Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 523d2487
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -927,7 +927,7 @@ numvar:
case '-':
p = makestrspace(NOPTS, expdest);
for (i = NOPTS - 1; i >= 0; i--) {
if (optlist[i]) {
if (optlist[i] && optletters[i]) {
USTPUTC(optletters[i], p);
len++;
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment