aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test (follow)
Commit message (Collapse)AuthorAgeFilesLines
* hush: fix several syntax corner cases with function definitionsDenys Vlasenko2025-08-184-0/+13
| | | | | | | | | | function old new delta parse_stream 3063 3075 +12 done_word 777 784 +7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 19/0) Total: 19 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: implement <<<here_string syntaxDenys Vlasenko2025-08-152-0/+68
| | | | | | | | | | | | | function old new delta setup_heredoc 299 351 +52 parse_stream 2514 2540 +26 parse_redirect 335 351 +16 redir_table 40 48 +8 static.setup_redirects 394 400 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/0 up/down: 108/0) Total: 108 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: undo incorrect change which allows a'b'=c to be assignmentDenys Vlasenko2025-08-142-0/+4
| | | | | | While at it, remove now-unused WORD_IS_KEYWORD Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: move tickquote1.tests to hush-bugs/ - it's a known bugDenys Vlasenko2025-08-142-0/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: remove the is_blank danceDenys Vlasenko2025-08-144-9/+17
| | | | | | | function old new delta parse_stream 2566 2524 -42 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix a corner case in "case" stmt, ctx_dsemicolon is in fact unusedDenys Vlasenko2025-08-134-0/+17
| | | | | | | | | | function old new delta parse_stream 2446 2476 +30 done_word 797 800 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 33/0) Total: 33 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: allow nested negation "! ! ! CMD" - bash 5.2.15 allows itDenys Vlasenko2025-08-122-4/+5
| | | | | | | | | | | | Also, deindent "ch == EOF" code branch in parse_stream() function old new delta done_word 799 797 -2 parse_stream 2453 2446 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-9) Total: -9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: drop ctx_inverted, use pipe->pi_invertedDenys Vlasenko2025-08-121-1/+1
| | | | | | | | | | | | function old new delta done_word 776 799 +23 parse_stream 2456 2453 -3 done_pipe 252 242 -10 .rodata 105837 105825 -12 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 23/-25) Total: -2 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: do not segfault on "for </dev/null v in..."Denys Vlasenko2025-08-122-0/+4
| | | | | | | This is not accepted by bash, we may also disallow this, but for now, at least do not crash Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: test for, and disallow several invalid syntaxesDenys Vlasenko2025-08-1120-0/+20
| | | | | | | | | | function old new delta parse_stream 2292 2456 +164 done_pipe 231 252 +21 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 185/0) Total: 185 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix var_backslash1.testsDenys Vlasenko2025-08-112-0/+19
| | | | | | | | | | | | | | | | | | function old new delta o_addqblock - 131 +131 append_str_maybe_ifs_split 53 100 +47 expand_one_var 1872 1897 +25 encode_then_expand_vararg 380 399 +19 sig_unblock 41 43 +2 sig_block 41 40 -1 sigprocmask_allsigs 33 31 -2 expand_vars_to_list 1080 1077 -3 wait_for_child_or_signal 202 193 -9 o_addQstr 175 42 -133 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 4/5 up/down: 224/-148) Total: 76 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shells: testcase: add another test for EINTR on fifo openDenys Vlasenko2025-08-112-0/+16
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: redir: Retry open on EINTRDenys Vlasenko2025-08-092-0/+15
| | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 28 May 2020 21:31:45 +1000 redir: Retry open64 on EINTR It is possible for open64 to block on named pipes, and therefore it can be interrupted by signals and return EINTR. We should only let it fail with EINTR if real signals are pending (i.e., it should not fail on SIGCHLD if SIGCHLD has not been trapped). This patch adds a new helper sh_open to retry the open64 call if necessary. It also calls sh_error when appropriate. Fixes: 3800d4934391 ("[JOBS] Fix dowait signal race") Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shells: fix a typo in var_backslash1.tests, expand it while at itDenys Vlasenko2025-08-092-4/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shells: add testsuite itemDenys Vlasenko2025-08-092-0/+62
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash,hush: fix corner cases with backslash-newlines in heredocsDenys Vlasenko2025-08-076-0/+15
| | | | | | | function old new delta fetch_heredocs 477 485 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: if !JOBS, skip tests which wouldn't workDenys Vlasenko2025-08-0313-2/+41
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix SEGV on "echo << >" and suchDenys Vlasenko2025-07-084-0/+6
| | | | | | | | | | function old new delta .rodata 105787 105823 +36 fetch_heredocs 461 477 +16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 52/0) Total: 52 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: improve bash compatibility of read built-inRon Yorston2025-07-012-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | Make the read built-in more compatible with bash: - Return an exit code of 142 on timeout. - When the timeout expires before a newline is detected in the input bash captures the partial input. This behaviour is new since bash version 4.4. BusyBox shells had the pre-4.4 behaviour where the input was lost. Update the tests to suit and fix a couple of compiler errors in the testsuite. function old new delta builtin_read 154 174 +20 readcmd 213 228 +15 shell_builtin_read 1364 1370 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 41/0) Total: 41 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* 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>