aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test (follow)
Commit message (Collapse)AuthorAgeFilesLines
* hush: do not exit interactive shell on some redirection errorsDenys Vlasenko2024-07-135-5/+8
| | | | | | | | | | | | | | | | | | | | $ echo >&99 hush: dup2(99,1): Bad file descriptor $ echo >&9999 hush: fcntl(1,F_DUPFD,10000): Invalid argument $ echo 2>/dev/tty 10>&9999 hush: fcntl(10,F_DUPFD,10000): Invalid argument $ still alive!_ function old new delta static.setup_redirects 334 394 +60 .rodata 105661 105712 +51 dup_CLOEXEC 49 79 +30 save_fd_on_redirect 263 277 +14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 155/0) Total: 155 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix "exec 3>FILE" aborting if 3 is exactly the next free fdDenys Vlasenko2024-07-132-0/+15
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix handling of single-quoted strings in pattern substitutionDenys Vlasenko2024-02-262-0/+12
| | | | | | | function old new delta subevalvar 1576 1588 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: detect when terminating "done"/"fi" is missingDenys Vlasenko2024-02-254-0/+6
| | | | | | | | | | function old new delta parse_stream 2271 2292 +21 .rodata 105408 105427 +19 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 40/0) Total: 40 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: disable check for "good" function name, bash does not check thisDenys Vlasenko2023-07-041-2/+2
| | | | | | | | | | function old new delta .rodata 105304 105261 -43 parse_command 1696 1633 -63 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-106) Total: -106 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell/math: bash-compatible handling of too large numbersDenys Vlasenko2023-06-254-4/+35
| | | | | | | | | | function old new delta parse_with_base - 170 +170 evaluate_string 1477 1309 -168 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 170/-168) Total: 2 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: typo fix in testsDenys Vlasenko2023-06-181-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell/math: fix ?: to not evaluate not-taken branchesDenys Vlasenko2023-06-1614-0/+42
| | | | | | | | | | | | | This fixes ash-arith-arith-ternary1/2.tests function old new delta evaluate_string 1271 1432 +161 arith_apply 968 1000 +32 arith 22 36 +14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 207/0) Total: 207 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell/math: fix order of expansion of variables to numbersDenys Vlasenko2023-06-152-0/+11
| | | | | | | | | | | | | This fixes arith-assign-in-varexp1.tests function old new delta evaluate_string 1132 1258 +126 arith_lookup_val 143 - -143 arith_apply 1132 977 -155 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/1 up/down: 126/-298) Total: -172 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell/math: remove special code to handle a?b?c:d:e, it works without it nowDenys Vlasenko2023-06-152-0/+3
| | | | | | | | | | | The "hack" to virtually parenthesize ? EXPR : made this unnecessary. The expression is effectively a?(b?(c):d):e and thus b?c:d is evaluated before continuing with the second : function old new delta evaluate_string 1148 1132 -16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell/math: fix parsing of ?: and explain why it's parsed that wayDenys Vlasenko2023-06-157-11/+23
| | | | | | | | | | | | | | | | | This fixes arith-precedence1.tests. This breaks arith-ternary2.tests again (we now evaluate variables on not-taken branches). We need a better logic here anyway: not only bare variables should not evaluate when not-taken: 1 ? eval_me : do_not_eval but any (arbitrarily complex) expressions shouldn't evaluate as well! 1 ? var_is_set=1 : ((var_is_not_set=2,var2*=4)) function old new delta evaluate_string 1097 1148 +51 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: sync ash/hush test scriptsDenys Vlasenko2023-06-141-4/+8
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell/math: fix the order of variable resolution in binopsDenys Vlasenko2023-06-148-0/+33
| | | | | | | function old new delta arith_apply 1134 1143 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix expansion of space in "a=${a:+$a }c" constructDenys Vlasenko2023-06-122-0/+8
| | | | | | | function old new delta encode_then_append_var_plusminus 554 552 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix ELIF cmd1;cmd2 THEN ... not executing cmd2, closes 15571Denys Vlasenko2023-05-254-0/+20
| | | | | | | function old new delta run_list 1012 1024 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: quote variable values printed by "set" (match ash behavior)Denys Vlasenko2023-04-131-2/+2
| | | | | | | function old new delta builtin_set 258 301 +43 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix ifs cleanup on error pathsDenys Vlasenko2022-08-022-0/+10
| | | | | | | | | | | | | Patch by Alex Gorinson <algore3698@gmail.com> function old new delta evalvar 477 495 +18 varvalue 603 618 +15 subevalvar 1557 1572 +15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 48/0) Total: 48 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: don't read past end of var in subvareval for bash substitutionsSören Tempel2022-03-012-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Without this patch, BusyBox handles bash pattern substitutions without a terminating '/' character incorrectly. Consider the following shell script: _bootstrapver=5.0.211-r0 _referencesdir="/usr/${_bootstrapver/-*}/Sources" echo $_referencesdir This should output `/usr/5.0.211/Sources`. However, without this patch it instead outputs `/usr/5.0.211Sources`. This is due to the fact that BusyBox expects the bash pattern substitutions to always be terminated with a '/' (at least in this part of subvareval) and thus reads passed the substitution itself and consumes the '/' character which is part of the literal string. If there is no '/' after the substitution then BusyBox might perform an out-of-bounds read under certain circumstances. When replacing the bash pattern substitution with `${_bootstrapver/-*/}`, or with this patch applied, ash outputs the correct value. Signed-off-by: Sören Tempel <soeren@soeren-tempel.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: fix script's comm field if ENABLE_FEATURE_PREFER_APPLETS=yDenys Vlasenko2021-10-112-0/+26
| | | | | | | | | | function old new delta re_execed_comm - 46 +46 main 72 86 +14 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 60/0) Total: 60 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: fix parsing of $(( (v)++ + NUM ))Denys Vlasenko2021-09-262-0/+7
| | | | | | | function old new delta evaluate_string 988 1011 +23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: enable more tests which are passing nowDenys Vlasenko2021-09-253-24/+37
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: fix arithmentic evaluation of "++7" and such (it is + + 7, i.e. 7)Denys Vlasenko2021-09-254-19/+25
| | | | | | | function old new delta evaluate_string 945 988 +43 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: LINENO starts from 0 in -c SCRIPT modeDenys Vlasenko2021-09-072-0/+4
| | | | | | The var_LINENO3.tests fails for hush: it does start from 0, but does not increment. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix LINENO in functionsDenys Vlasenko2021-09-072-0/+11
| | | | | | | | | | | | | | | | | | | From larger patch by Roberto A. Foglietta <roberto.foglietta@gmail.com> function old new delta evalfun 348 369 +21 ash_main 1202 1218 +16 setinputstring 65 73 +8 lookupvar 116 106 -10 evaltree 772 753 -19 evalsubshell 192 173 -19 evalfor 175 156 -19 evalcase 273 254 -19 evalcommand 1560 1536 -24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/6 up/down: 45/-110) Total: -65 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix set -n to act immediately, not just after run_list()Denys Vlasenko2021-09-074-0/+14
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: update psubst testcasesDenys Vlasenko2021-07-274-6/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: implement $'str' bashismDenys Vlasenko2021-07-266-0/+36
| | | | | | | | | | | function old new delta parse_dollar_squote - 441 +441 encode_then_expand_vararg 359 380 +21 parse_stream 2252 2271 +19 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 481/0) Total: 481 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ahell: update testsuiteDenys Vlasenko2021-07-251-3/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix bkslash+newline handling and number validation in ${NN} and ${#NN}Denys Vlasenko2021-06-193-1/+19
| | | | | | | | | | | | | Entering "${1a}" into interactive shell was making it exit. function old new delta parse_dollar 824 958 +134 i_getch_and_eat_bkslash_nl - 44 +44 parse_expr 917 938 +21 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 199/0) Total: 199 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix handling of \^C and "^C"Denys Vlasenko2021-06-154-0/+6
| | | | | | | | | | function old new delta parse_stream 2238 2252 +14 encode_string 243 256 +13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 27/0) Total: 27 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* typo fixDenys Vlasenko2020-12-251-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix this case: echo "SCRIPT" | hushDenys Vlasenko2020-12-252-0/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix fallout from tweaking ${var:START:LEN} codeDenys Vlasenko2020-12-232-0/+3
| | | | | | | function old new delta expand_one_var 2344 2353 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: document bugs in [[ =~ ]] comparisonDenys Vlasenko2020-11-014-0/+28
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: add tests for unquoted < > in [[ ]]Denys Vlasenko2020-10-312-0/+5
| | | | | | They pass. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: better support of [[ ]] bashismDenys Vlasenko2020-10-3110-0/+79
| | | | | | | | | | | | | | | | | | Still rather rudimentary for ash function old new delta binop 433 589 +156 check_operator 65 101 +36 done_word 736 769 +33 test_main 405 418 +13 parse_stream 2227 2238 +11 ops_texts 124 133 +9 ops_table 80 86 +6 run_pipe 1557 1562 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 8/0 up/down: 269/0) Total: 269 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: output bash-compat killing signal namesDenys Vlasenko2020-10-246-5/+53
| | | | | | | | | This significantly syncronises ash-signals and hush-signals tests. function old new delta process_wait_result 449 450 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: do not print killing signal name in `cmd_whihc_dies_on_signal`Denys Vlasenko2020-10-242-0/+2
| | | | | | | function old new delta process_wait_result 438 449 +11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: add testsuite for "wait $pid" waiting for other tasksDenys Vlasenko2020-09-292-0/+9
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: Fix "read -d ''" behaviorChristian Eggers2020-07-312-0/+2
| | | | | | | | | | | | | | With bash's read builtin it is possible to read from a file (e.g. device-tree) until the first '\0' character: IFS= read -r -d '' VARIABLE < file In busybox ash the -d extension is also implemented, but checking the read character for '\0' has to be performed after comparing with the delimiter. Signed-off-by: Christian Eggers <ceggers@arri.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shells: fix exitcode_trapN tests to avoid racesDenys Vlasenko2020-02-262-4/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: expand: Ensure result is escaped in cvtnumDenys Vlasenko2020-02-212-0/+10
| | | | | | | | | | | | | | | | | | Upstream commit: Date: Fri, 1 Jun 2018 18:25:29 +0800 expand: Ensure result is escaped in cvtnum The minus sign generated from arithmetic expansion is currently unquoted which causes anomalies when the result is used in where the quoting matters. This patch fixes it by explicitly calling memtodest on the result in cvtnum. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: make "exit" in trap use pre-trap exitcode - fix for nested trapDenys Vlasenko2020-02-212-0/+13
| | | | | | | function old new delta check_and_run_traps 276 278 +2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: implement "return NUM in trap sets $? after trap"Denys Vlasenko2020-02-206-0/+34
| | | | | | | | | | | | | function old new delta builtin_return 47 67 +20 check_and_run_traps 243 259 +16 run_pipe 1583 1597 +14 hush_main 1076 1086 +10 run_list 1054 1055 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/0 up/down: 61/0) Total: 61 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash,hush: testcase for "exit" without arguments in a trapDenys Vlasenko2020-02-192-0/+10
| | | | | | hush fails this one Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: expand: Fix trailing newlines processing in backquote expandingDenys Vlasenko2020-02-172-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Mon, 29 Apr 2019 19:13:37 +0500 expand: Fix trailing newlines processing in backquote expanding According to POSIX.1-2008 we should remove newlines only at the end of the substitution. Newlines-only substitions causes dash to remove newlines before beggining of the substitution. The following code: cat <<END 1 $(echo "") 2 END prints "1<newline>2" instead of expected "1<newline><newline>2". This patch fixes trailing newlines processing in backquote expanding. Signed-off-by: Nikolai Merinov <n.merinov@inango-systems.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: parser: Only accept single-digit parameter expansion outside of bracesDenys Vlasenko2020-02-172-0/+7
| | | | | | | | | | | | | Upstream commit: Date: Mon, 27 May 2019 13:39:37 +0800 parser: Only accept single-digit parameter expansion outside of braces This patch should fix the problem. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: restore redirected stdinDenys Vlasenko2019-11-012-0/+10
| | | | | | | | | | | | | function old new delta restore_redirects 52 95 +43 save_fd_on_redirect 243 253 +10 hfopen 90 99 +9 fgetc_interactive 259 261 +2 builtin_type 117 115 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 64/-2) Total: 62 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: remove test for "echo ${-}" errorring out - now it worksDenys Vlasenko2019-05-192-3/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix quoted "${notexist-}" expansion to not disappearDenys Vlasenko2019-05-152-0/+7
| | | | | | | function old new delta expand_one_var 2296 2311 +15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>