aboutsummaryrefslogtreecommitdiff
path: root/shell/ash_test/ash-vars (follow)
Commit message (Collapse)AuthorAgeFilesLines
* hush: IFS fixesDenys Vlasenko2018-04-112-0/+9
| | | | | | | | | | | | | | | | | | $ IFS=": "; x=" "; set x $x; for v; do echo "|$v|"; done |x| $ IFS=": "; x=":"; set x $x; for v; do echo "|$v|"; done |x| || function old new delta run_pipe 1789 1870 +81 expand_on_ifs 310 361 +51 pseudo_exec_argv 588 591 +3 builtin_local 50 53 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 138/0) Total: 138 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: parser: Allow newlines within parameter substitutionDenys Vlasenko2018-04-112-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 22 Mar 2018 21:41:24 +0800 parser: Allow newlines within parameter substitution On Fri, Mar 16, 2018 at 11:27:22AM +0800, Herbert Xu wrote: > On Thu, Mar 15, 2018 at 10:49:15PM +0100, Harald van Dijk wrote: > > > > Okay, it can be trivially modified to something that does work in other > > shells (even if it were actually executed), but gets rejected at parse time > > by dash: > > > > if false; then > > : ${$+ > > } > > fi > > That's just a bug in dash's parser with ${} in general, because > it bombs out without the if clause too: > > : ${$+ > } This patch fixes the parsing of newlines with parameter substitution. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: parser: Add syntax stack for recursive parsingDenys Vlasenko2018-04-026-12/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* shells: fix var_LINENO1.tests false positive, add it to ash tests tooDenys Vlasenko2018-03-312-0/+14
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash testsuite: add two hush tests from last commitDenys Vlasenko2018-01-254-0/+10
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: echo ${?:0} was fixed sometime ago, enable it in testsDenys Vlasenko2018-01-132-1/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: update testsuite (we now error out on ${#=})Denys Vlasenko2017-08-141-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: remove ${#+} tests, it is not a valid constructDenys Vlasenko2017-07-262-3/+8
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix ${##}, ${#?}, ${#!} handlingDenys Vlasenko2017-07-263-1/+43
| | | | | | | | | | function old new delta parse_dollar 786 820 +34 expand_one_var 1579 1592 +13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 47/0) Total: 47 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: [VAR] Move unsetvar functionality into setvareqDenys Vlasenko2017-07-253-1/+58
| | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Tue, 25 May 2010 20:55:05 +0800 [VAR] Move unsetvar functionality into setvareq This patch moves the unsetvar code into setvareq so that we can no have a pathological case of an unset variable hanging around unless it has a bit pinning it like VEXPORT. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta setvareq 227 303 +76 expmeta 517 521 +4 localcmd 364 366 +2 unsetcmd 96 76 -20 unsetvar 129 7 -122 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/2 up/down: 82/-142) Total: -60 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: import param_expand_default.tests from hushDenys Vlasenko2017-07-252-0/+30
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: treat ${#?} as "length of $?"Denys Vlasenko2017-07-252-0/+104
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: add a few tests from hush-vars/*Denys Vlasenko2017-07-256-0/+251
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: suppress readonly1.tests false positive; add readonly0.testsDenys Vlasenko2017-07-214-4/+62
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: more general format ${var:EXPR:EXPR}Denys Vlasenko2017-07-172-0/+47
| | | | | | | | function old new delta subevalvar 1171 1202 +31 localcmd 364 366 +2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* typo fixDenys Vlasenko2017-07-061-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: implement negative start in the ${v: -n[:m]} idiomDenys Vlasenko2017-07-062-0/+14
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: "adopt" ash var-utf8-length.testsDenys Vlasenko2017-07-061-0/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix interactive "command eval STRING" exiting on errors.Denys Vlasenko2016-10-282-0/+9
| | | | | | This bug is also present in current dash Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: [PARSER] Fix parsing of ${##1}Denys Vlasenko2016-10-262-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 4 Oct 2007 22:15:10 +0800 [PARSER] Fix parsing of ${##1} Previously dash treated ${##1} as a length operation. This patch fixes that. Test case: set -- a echo ${##1}OK Old result: 1OK New result: OK This was a real bug in ash (but not in hush). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash testsuite: add most of hust tests which pass for ashDenys Vlasenko2016-10-0322-0/+170
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sh testsuite: sync ash-vars/ and hush-vars/Denys Vlasenko2016-10-028-20/+39
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash testsuite: update some of variable tests with newer versions from hushDenys Vlasenko2016-10-026-25/+156
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: expand: Fixed "$@" expansion when EXP_FULL is falseDenys Vlasenko2016-10-022-0/+37
| | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 1 Jan 2015 07:53:10 +1100 expand: Fixed "$@" expansion when EXP_FULL is false The commit 3c06acdac0b1ba0e0acdda513a57ee6e31385dce ([EXPAND] Split unquoted $@/$* correctly when IFS is set but empty) broke the case where $@ is in quotes and EXP_FULL is false. In that case we should still emit IFS as field splitting is not performed. Reported-by: Juergen Daubert <jue@jue.li> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: [EXPAND] Do not split quoted VSLENGTH and VSTRIMDenys Vlasenko2016-10-014-0/+33
| | | | | | | | | | | | | | Upstream patch: Date: Wed, 8 Oct 2014 15:42:08 +0800 [EXPAND] Do not split quoted VSLENGTH and VSTRIM Currently VSLENGTH and VSTRIM* are field-split even within quotes. This is obviously wrong. This patch fixes that. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: [EXPAND] Split unquoted $@/$* correctly when IFS is set but emptyDenys Vlasenko2016-10-012-0/+46
| | | | | | | | | | | | | | Upstream commit: Date: Wed, 8 Oct 2014 15:24:23 +0800 [EXPAND] Split unquoted $@/$* correctly when IFS is set but empty Currently we do not field-split $@/$* when it isn't quoted and IFS is set but empty. This is obviously wrong. This patch fixes this. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell testsuite: add trailing newline to var_unbackslash1.testsDenys Vlasenko2016-09-291-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix arithmetic closing )) split by backslash-newlineDenys Vlasenko2016-09-292-0/+24
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: rework input char buffering to allow more than one-deep peekDenys Vlasenko2016-09-298-0/+159
| | | | | | | | | | | | | | | | | | | | | This fixes backslash+newline continuation in $VAR\ NAME construct. (ash has a bug there as well). function old new delta file_peek2 - 74 +74 parse_dollar 746 773 +27 expand_vars_to_list 1143 1167 +24 setup_string_in_str 32 46 +14 setup_file_in_str 33 47 +14 file_get 264 278 +14 static_peek2 - 7 +7 file_peek 91 72 -19 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 5/1 up/down: 174/-19) Total: 155 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix handling of ${VAR: -2}Denys Vlasenko2016-07-252-0/+17
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix corruption of ${#var} if $var contains UTF-8 charactersRon Yorston2016-03-222-0/+3
| | | | | | | | | | | | | | | | | | | | | | As reported in bug 8506: $ X=abcdÉfghÍjklmnÓpqrstÚvwcyz $ echo ${#X} abcd26 The result should be 26. This regression was introduced by: <d68d1fb> 2015-05-18 [Ron Yorston] ash: code shrink around varvalue The length in characters was being used to discard the contents of the variable instead of the length in bytes. URL: https://bugs.busybox.net/8506 Reported-by: Martijn Dekker <martijn@inlv.org> Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* testsuite: add some tests for ashRon Yorston2015-05-1810-0/+15
| | | | | Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: move parse-time quote flag detection to run-timeRon Yorston2015-05-184-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because the parser does not recursively parse parameter expansion with respect to quotes, we can't accurately determine quote status at parse time. This patch works around this by moving the quote detection to run-time where we do interpret it recursively. Test case: foo=\\ echo "<${foo#[\\]}>" Old result: <\> New result: <> Do not quote back slashes in parameter expansions outside quotes. Test case: a=/b/c/* b=\\ echo ${a%$b*} Old result: /b/c/* New result: /b/c/ Based on commits 880d952, 7cfd8be, 0d7d660 and a7c21a6 from git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu function old new delta argstr 1164 1193 +29 memtodest 147 174 +27 subevalvar 1153 1177 +24 redirect 1279 1282 +3 dolatstr 5 7 +2 static.spclchars 10 9 -1 expandarg 962 960 -2 evalcase 273 271 -2 evalcommand 1204 1197 -7 rmescapes 236 227 -9 preglob 27 8 -19 evalvar 604 582 -22 cmdputs 389 334 -55 readtoken1 3163 3061 -102 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/9 up/down: 85/-219) Total: -134 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: remove arithmetic expansion collapsing at parse timeRon Yorston2015-05-182-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Collapsing arithmetic expansion is incorrect when the inner arithmetic expansion is a part of a parameter expansion. Test case: unset a echo $((3 + ${a:=$((4 + 5))})) echo $a Old result: 12 (4 + 5) New result: 12 9 Based on commit bb777a6 from git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu function old new delta readtoken1 3180 3163 -17 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: do not expand tilde in parameter expansion within quotesRon Yorston2015-05-182-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Test case: unset a echo "${a:-~root}" Old result: /root New result: ~root Based on commit 170f44d from git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu function old new delta evalvar 598 604 +6 parse_command 1440 1443 +3 localcmd 325 327 +2 readtoken1 3199 3200 +1 argstr 1180 1164 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 12/-16) Total: -4 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: perform tilde expansion in all parameter expansion wordsRon Yorston2015-05-182-0/+3
| | | | | | | | | | | | | | | | | | | | | Previously tilde expansion was not carried out for =?#% expansion words. Test case: a=~root:~root echo ${a#~root} Old result: /root:/root New result: :/root Based on commit dd721f71 from git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu function old new delta subevalvar 1152 1153 +1 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix handling of duplicate "local"Denys Vlasenko2015-04-182-0/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: add support for ${var/pattern/repl}, conditional on bash compatDenys Vlasenko2010-09-051-7/+0
| | | | | | | | | | | | function old new delta expand_vars_to_list 2386 2833 +447 expand_string_to_string 69 110 +41 parse_dollar 681 721 +40 hush_main 963 945 -18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 528/-18) Total: 510 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* hush: fix handling of backslashes in variable assignmentDenys Vlasenko2010-09-041-2/+2
| | | | Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* ash: add another ${v/a/b} test we currently failDenys Vlasenko2010-08-302-0/+15
| | | | Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* ash: fix another bit of var_bash4 bugDenys Vlasenko2010-08-072-2/+2
| | | | | | | | | | But it _still_ doesn't pass! quoted case is a tough nut to crack function old new delta redirect 1281 1286 +5 subevalvar 1141 1142 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* var_bash4.tests: better wording in commentDenys Vlasenko2010-08-061-4/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* update var_bash4 test. one more bug revealed by it now...Denys Vlasenko2010-08-062-8/+68
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: extend var_bash4.tests; nocode changesDenys Vlasenko2010-08-052-2/+7
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: add a testcase for bug 2281 (currently fails). Small code cleanups.Denys Vlasenko2010-08-054-40/+52
| | | | | | | | | | | function old new delta changepath 195 192 -3 subevalvar 1204 1200 -4 readtoken1 3247 3240 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-14) Total: -14 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix var_leak.tests so that it actually catches the NOFORK bugDenys Vlasenko2010-05-182-1/+7
| | | | | | + document the bug better Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix var_leak testcaseDenys Vlasenko2010-05-182-6/+16
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix ${var/s/r} handling, add testcase.Denis Vlasenko2008-06-142-0/+61
|
* ash: add another testsuite entry ("leaking variables" bug)Denis Vlasenko2008-04-132-0/+11
|
* ash: a bit more complete POSIX subst testsuite entryDenis Vlasenko2008-04-122-2/+17
|