mirror of
https://codeberg.org/landley/toybox.git
synced 2026-01-26 06:07:55 +00:00
Fix backslash parsing in $'' so \' doesn't end quote context.
This commit is contained in:
parent
cfef2aabc1
commit
97b5ea16cf
@ -723,9 +723,12 @@ testing '[[1<2]] is alphabetical, not numeric' '[[ 123 < 19 ]] && echo yes' \
|
||||
'yes\n' '' ''
|
||||
testing '[[~]]' '[[ ~ == $HOME ]] && echo yes' 'yes\n' '' ''
|
||||
|
||||
$BROKEN testing 'quoting contexts nest' \
|
||||
$'echo -n "$(echo "hello $(eval $\'echo -\\\\\\ne \\\'world\\n \\\'\')")"' \
|
||||
# The trailing space is because the \n gets stripped off otherwise
|
||||
testing 'quoting contexts nest' \
|
||||
$'echo -n "$(echo "hello $(eval $\'echo -\\\\\\ne \\\'world\\n \\\'\')")"' \
|
||||
'hello world\n ' '' ''
|
||||
testing "\$'' suppresses variable expansion" \
|
||||
$'echo $\'$(abc\'' '$(abc\n' '' ''
|
||||
|
||||
testing 'if; is a syntax error but if $EMPTY; is not' \
|
||||
'if $NONE; then echo hello; fi' 'hello\n' '' ''
|
||||
|
||||
@ -1128,7 +1128,7 @@ static char *parse_word(char *start, int early)
|
||||
else if (qq==254) return start+1;
|
||||
else if (qq==255) toybuf[quote-1] = ')';
|
||||
} else if (ii==')') quote--;
|
||||
} else if (ii==qq) quote--; // matching end quote
|
||||
} else if (ii==(qq&127)) quote--; // matching end quote
|
||||
else if (qq!='\'') end--, ii = 0; // single quote claims everything
|
||||
if (ii) continue; // fall through for other quote types
|
||||
|
||||
@ -1146,11 +1146,11 @@ static char *parse_word(char *start, int early)
|
||||
|
||||
// \? $() ${} $[] ?() *() +() @() !()
|
||||
else {
|
||||
if (ii=='$' && -1!=(qq = stridx("({[", *end))) {
|
||||
if (ii=='$' && qq != 0247 && -1!=(qq = stridx("({['", *end))) {
|
||||
if (strstart(&end, "((")) {
|
||||
end--;
|
||||
toybuf[quote++] = 255;
|
||||
} else toybuf[quote++] = ")}]"[qq];
|
||||
} else toybuf[quote++] = ")}]\247"[qq]; // last is '+128
|
||||
} else if (*end=='(' && strchr("?*+@!", ii)) toybuf[quote++] = ')';
|
||||
else {
|
||||
if (ii!='\\') end--;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user