Age | Commit message (Collapse) | Author |
|
Upstream email:
parser: Fix parameter expansion inside inner double quotes
The parsing of parameter expansion inside inner double quotes
breaks because we never look for ENDVAR while innerdq is true.
echo "${x#"${x+''}"''}
This patch fixes it by pushing the syntax stack if innerdq is
true and we enter a new parameter expansion.
This patch also fixes a corner case where a bad substitution error
occurs within arithmetic expansion.
Reported-by: Denys Vlasenko <vda.linux@googlemail.com>
Fixes: ab1cecb40478 (" parser: Add syntax stack for recursive...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
function old new delta
readtoken1 2880 2898 +18
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
run_list 1270 1053 -217
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
This closes 10821.
Upstream patch:
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Fri, 9 Mar 2018 00:14:02 +0800
parser: Add syntax stack for recursive parsing
Without a stack of syntaxes we cannot correctly these two cases
together:
"${a#'$$'}"
"${a#"${b-'$$'}"}"
A recursive parser also helps in some other corner cases such
as nested arithmetic expansion with paratheses.
This patch adds a syntax stack allocated from the stack using
alloca. As a side-effect this allows us to remove the naked
backslashes for patterns within double-quotes, which means that
EXP_QPAT also has to go.
This patch also fixes removes any backslashes that precede right
braces when they are present within a parameter expansion context,
and backslashes that precede double quotes within inner double
quotes inside a parameter expansion in a here-document context.
The idea of a recursive parser is based on a patch by Harald van
Dijk.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
var_bash3, var_bash4 and var_bash6 tests are updated
with the output given by bash-4.3.43
With this patch, the following tests now pass for ash:
dollar_repl_slash_bash2.tests
squote_in_varexp2.tests
squote_in_varexp.tests
var_bash4.tests
function old new delta
readtoken1 2615 2874 +259
synstack_push - 54 +54
evalvar 574 571 -3
rmescapes 330 310 -20
subevalvar 1279 1258 -21
argstr 1146 1107 -39
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/4 up/down: 313/-83) Total: 230 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
This fails for ash. hush works.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
It turns out bkslash_in_varexp.tests was a bash bug :]
ash and hush fail "corrected" bkslash_in_varexp.tests as well,
just not as badly as I thought (hush gets half of the cases right).
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
readtoken1 2602 2608 +6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
This patch is a backport from dash of the combination of:
[SHELL] Add preliminary LINENO support
[VAR] Fix varinit ordering that broke fc
[SHELL] Improve LINENO support
function old new delta
parse_command 1604 1677 +73
calcsize 156 223 +67
copynode 196 258 +62
evalcommand 1546 1606 +60
ash_main 1046 1103 +57
lookupvar 51 106 +55
evalcase 269 317 +48
evaltree 501 547 +46
evalfor 156 200 +44
evalsubshell 156 195 +39
raise_error_syntax 11 29 +18
varinit_data 120 132 +12
evalfun 270 280 +10
funcline - 4 +4
cmdtxt 569 572 +3
trapcmd 306 304 -2
ash_vmsg 153 150 -3
startlinno 4 - -4
funcnest 4 - -4
xxreadtoken 263 250 -13
readtoken1 2645 2602 -43
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 14/4 up/down: 598/-69) Total: 529 bytes
text data bss dec hex filename
932834 481 6864 940179 e5893 busybox_old
933375 481 6856 940712 e5aa8 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Basen on the patch from Martijn Dekker <martijn@inlv.org>
function old new delta
evalcommand 1161 1302 +141
maybe_single_quote - 60 +60
getoptscmd 527 546 +19
readtoken1 2819 2823 +4
localcmd 366 364 -2
evaltreenr 495 479 -16
evaltree 495 479 -16
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/3 up/down: 224/-34) Total: 190 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Add a testcase which tests all ASCII punctuation escapes.
NB: hush is failing this test!
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Bash doesn't expand its $'...' construct in double quotes:
$ echo "$'a\tb'"
$'a\tb'
Change BusyBox ash to do the same. This also fixes a problem with
here documents where BusyBox ash gave an incorrect result for:
$ cat <<EOF
> '$'
> EOF
'$'
Reported-by: Timo Teras <timo.teras@iki.fi>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
subevalvar 1152 1178 +26
readtoken1 3267 3275 +8
redirect 1284 1286 +2
expandarg 957 958 +1
expdir 4 - -4
evalcommand 1219 1209 -10
expmeta 481 469 -12
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 4/2 up/down: 37/-26) Total: 11 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
readtoken1 2824 3172 +348
static.C_escapes - 18 +18
parse_command 1504 1500 -4
SIT 89 83 -6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/2 up/down: 366/-10) Total: 356 bytes
|