summaryrefslogtreecommitdiff
path: root/shell (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
| * hush: IFS fixesDenys Vlasenko2018-04-115-2/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $ 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>
| * hush: fix "$v" expansion in case patterns when v='[a]'Denys Vlasenko2018-04-115-16/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta run_list 1053 1063 +10 setup_redirects 311 320 +9 encode_then_expand_string 135 142 +7 run_pipe 1784 1789 +5 expand_assignments 81 86 +5 expand_string_to_string 124 125 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 6/0 up/down: 37/0) Total: 37 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: parser: Allow newlines within parameter substitutionDenys Vlasenko2018-04-115-1/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * hush: optimize parse_stream()Denys Vlasenko2018-04-111-28/+31
| | | | | | | | | | | | | | | | | | | | Since we check for '\' anyway when we determine whether we can look ahead, we can just check for *and handle* it there. function old new delta parse_stream 2751 2740 -11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: do not drop backslash from eval 'echo ok\'Denys Vlasenko2018-04-116-8/+22
| | | | | | | | | | | | | | | | | | | | | | | | newer bash does not drop it, most other shells too function old new delta unbackslash 39 57 +18 parse_stream 2753 2751 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 18/-2) Total: 16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: add comments about [[, no code changesDenys Vlasenko2018-04-102-1/+26
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix handling of \<eof> in double-quoted stringsDenys Vlasenko2018-04-103-5/+12
| | | | | | | | | | | | | | function old new delta encode_string 268 250 -18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix eval 'echo ok\'Denys Vlasenko2018-04-103-5/+11
| | | | | | | | | | | | | | function old new delta parse_stream 2762 2753 -9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: simplify \<newline> code, part 3Denys Vlasenko2018-04-101-55/+45
| | | | | | | | | | | | | | function old new delta parse_stream 2780 2762 -18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: simplify \<newline> code, part 2Denys Vlasenko2018-04-101-30/+30
| | | | | | | | | | | | | | function old new delta parse_stream 2787 2780 -7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: simplify \<newline> code, part 1Denys Vlasenko2018-04-101-11/+11
| | | | | | | | | | | | | | function old new delta parse_stream 2919 2787 -132 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: put "current word" structure into parsing contextDenys Vlasenko2018-04-101-122/+120
| | | | | | | | | | | | | | | | | | | | function old new delta done_word 790 767 -23 parse_stream 3018 2919 -99 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-122) Total: -122 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: if "[[" bashism is not supported, do not handle it anywhereDenys Vlasenko2018-04-101-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: trivial code shrinkDenys Vlasenko2018-04-101-1/+2
| | | | | | | | | | | | | | function old new delta parse_command 1677 1674 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix var_leaks.tests and var_preserved.tests on NOMMUDenys Vlasenko2018-04-091-49/+59
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta remove_nested_vars - 77 +77 run_pipe 1756 1786 +30 pseudo_exec_argv 376 379 +3 leave_var_nest_level 98 32 -66 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/1 up/down: 110/-66) Total: 44 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix func_return2.tests on NOMMUDenys Vlasenko2018-04-091-0/+7
| | | | | | | | | | | | | | function old new delta hush_main 1714 1718 +4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: make loopnest a global variableRon Yorston2018-04-131-1/+2
| | | | | | | | Fixes the test ash-misc/break5.tests.
* | ash: make commandname a global variableRon Yorston2018-04-121-2/+7
| | | | | | | | | | | | | | commandname is static so isn't copied during forkshell. This was causing the arith-tests script in the shell test suite to fail because without commandname some error reports were missing line numbers.
* | ash: make struct forkshell a local variable in evalbackcmdRon Yorston2018-04-101-7/+7
| | | | | | | | | | | | There's no reason for the forkshell structure to be passed between expbackq and evalbackcmd in the backcmd structure. It can be a local variable, as in the other similar cases.
* | ash: make 'read -s' workRon Yorston2018-04-101-1/+2
| | | | | | | | | | | | Raw input should also be used when the -s flag is present. Related to GitHub issue #112.
* | Merge branch 'busybox' into mergeRon Yorston2018-04-0956-516/+840
|\|
| * bzip2: fix two crashes on corrupted archivesDenys Vlasenko2018-04-081-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As it turns out, longjmp'ing into freed stack is not healthy... function old new delta unpack_usage_messages - 97 +97 unpack_bz2_stream 369 409 +40 get_next_block 1667 1677 +10 get_bits 156 155 -1 start_bunzip 212 183 -29 bb_show_usage 181 120 -61 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/3 up/down: 147/-91) Total: 56 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb.h: always include sys/resource.hDenys Vlasenko2018-04-081-1/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix prompt in multi-line $(())Denys Vlasenko2018-04-071-12/+22
| | | | | | | | | | | | | | | | | | Now shows PS2 in this case: /path/to/dir $ a=b; echo $(( > _ Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix "unset PS1/PS2", and put them into initial variable setDenys Vlasenko2018-04-061-29/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | "unset PS1/PS2" causes prompts to be empty strings function old new delta hush_main 1031 1089 +58 goto_new_line 27 33 +6 fgetc_interactive 244 245 +1 unset_local_var 155 149 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 65/-6) Total: 59 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: if we did match "LINENO" or "OPTIND", stop further comparisonsDenys Vlasenko2018-04-061-2/+6
| | | | | | | | | | | | | | function old new delta handle_changed_special_names 99 101 +2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: consolidate handling of setting/unsetting of PSn, LINENO, OPTINDDenys Vlasenko2018-04-061-29/+30
| | | | | | | | | | | | | | | | | | | | | | function old new delta handle_changed_special_names - 99 +99 unset_local_var 256 155 -101 set_local_var 557 437 -120 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/2 up/down: 99/-221) Total: -122 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: update to correctly handle changed var_bash[346].testsDenys Vlasenko2018-04-051-6/+6
| | | | | | | | | | | | | | function old new delta expand_one_var 1612 1604 -8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: implement "hush -s"Denys Vlasenko2018-04-052-9/+9
| | | | | | | | | | | | | | | | | | | | function old new delta hush_main 1015 1031 +16 packed_usage 32757 32745 -12 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 16/-12) Total: 4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix a few more corner cases with empty-expanding `cmds`Denys Vlasenko2018-04-055-8/+46
| | | | | | | | | | | | | | | | | | See added testcases function old new delta run_pipe 1723 1784 +61 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix corner cases with exec in empty expansionsDenys Vlasenko2018-04-055-17/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cases like these: var=val exec >redir var=val `` >redir function old new delta run_pipe 1701 1723 +22 redirect_and_varexp_helper 56 55 -1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 22/-1) Total: 21 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: less mind-bending set_vars_and_save_old()Denys Vlasenko2018-04-051-71/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta run_pipe 1651 1701 +50 set_local_var 510 557 +47 pseudo_exec_argv 544 581 +37 redirect_and_varexp_helper 64 56 -8 set_vars_and_save_old 164 149 -15 unset_local_var 274 256 -18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/3 up/down: 134/-41) Total: 93 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: "no logic changes" in last commit was not true, fix it upDenys Vlasenko2018-04-051-1/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: make run_pipe code simpler to understand, no logic changesDenys Vlasenko2018-04-051-66/+57
| | | | | | | | | | | | | | function old new delta run_pipe 1641 1651 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix a bug where we don't properly handle f() { a=A; b=B; }; a= fDenys Vlasenko2018-04-055-82/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta unset_local_var 20 274 +254 leave_var_nest_level - 98 +98 set_vars_and_save_old 128 164 +36 enter_var_nest_level - 32 +32 builtin_local 46 50 +4 pseudo_exec_argv 554 544 -10 redirect_and_varexp_helper 77 64 -13 run_pipe 1890 1641 -249 unset_local_var_len 267 - -267 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 3/3 up/down: 424/-539) Total: -115 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: make var nesting code independent of "local" supportDenys Vlasenko2018-04-041-40/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, add code to abort at ~65000 function recursion depth. SEGVing is not as nice as exiting with a message (and restoring termios!): $ f() { echo -n .; f; }; f ....<many dots later>....hush: fatal recursion (depth 65281) function old new delta run_pipe 1826 1890 +64 pseudo_exec_argv 544 554 +10 parse_and_run_file 71 80 +9 i_getch 104 107 +3 done_command 99 102 +3 set_local_var 508 510 +2 helper_export_local 214 215 +1 builtin_local 49 46 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 7/1 up/down: 92/-3) Total: 89 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix for readonly vars in "ro=A ro=B cmd" caseDenys Vlasenko2018-04-043-13/+21
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: unbreak PS1 parsing after "ash: parser: Add syntax stack..." commitDenys Vlasenko2018-04-041-1/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: support "f() (cmd)" functionsDenys Vlasenko2018-04-036-40/+59
| | | | | | | | | | | | | | | | | | Many other shells support this construct function old new delta parse_stream 2950 3018 +68 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix mishandling of "true | f() { echo QWE; }"Denys Vlasenko2018-04-031-0/+9
| | | | | | | | | | | | | | function old new delta run_pipe 1820 1826 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix "set -e; false || x=1; echo OK"Denys Vlasenko2018-04-035-7/+43
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: one-word, no-globbing handling of local/export/readonly argsDenys Vlasenko2018-04-031-21/+32
| | | | | | | | | | | | | | function old new delta done_word 738 790 +52 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: parser: Fix parameter expansion inside inner double quotesDenys Vlasenko2018-04-023-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * hush: fix a backslash-removal bug in caseDenys Vlasenko2018-04-025-3/+37
| | | | | | | | | | | | | | function old new delta run_list 1270 1053 -217 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: expand: Fix bugs with words connected to the right of $@Denys Vlasenko2018-04-025-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream email: This is actually composed of two bugs. First of all our tracking of quotemark is wrong so anything after "$@" becomes quoted. Once we fix that then the problem is that the first space character after "$@" is not recognised as an IFS. This patch fixes both. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: redir: Fix typo in noclobber codeDenys Vlasenko2018-04-021-1/+1
| | | | | | | | | | | | Upstream commit "redir: Fix typo in noclobber code" Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: parser: Fix single-quoted patterns in here-documentsDenys Vlasenko2018-04-023-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: From: Herbert Xu <herbert@gondor.apana.org.au> Date: Fri, 9 Mar 2018 23:07:53 +0800 parser: Fix single-quoted patterns in here-documents The script x=* cat <<- EOF ${x#'*'} EOF prints * instead of nothing as it should. The problem is that when we're in sqsyntax context in a here-document, we won't add CTLESC as we should. This patch fixes it: Reported-by: Harald van Dijk <harald@gigawatt.nl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: remove stray debugging printoutDenys Vlasenko2018-04-021-1/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: parser: Add syntax stack for recursive parsingDenys Vlasenko2018-04-0219-121/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | win32: more backslash to slash conversionsRon Yorston2018-04-081-0/+3
| | | | | | | | | | | | | | | | | | Convert backslashes to slashes: - in the main program's argv[0] - in the shell's file argument Also, fix the code to remove the .exe extension from argv[0] in the main program.