aboutsummaryrefslogtreecommitdiff
path: root/shell (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
| * shell/math: add note on ERANGEDenys Vlasenko2023-06-181-4/+11
| | | | | | | | | | | | | | function old new delta evaluate_string 1488 1478 -10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: explain why we use separate &endDenys Vlasenko2023-06-181-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: code shrinkDenys Vlasenko2023-06-181-2/+5
| | | | | | | | | | | | | | function old new delta evaluate_string 1498 1491 -7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: eliminate redundant endofname()Denys Vlasenko2023-06-181-8/+8
| | | | | | | | | | | | | | function old new delta evaluate_string 1486 1498 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: typo fix in testsDenys Vlasenko2023-06-182-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: code shrinkDenys Vlasenko2023-06-181-11/+12
| | | | | | | | | | | | | | function old new delta evaluate_string 1489 1486 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: decrease stack usage by not allocating copies of variable namesDenys Vlasenko2023-06-181-32/+51
| | | | | | | | | | | | | | | | | | | | | | | | We risk exhaust stack with alloca() with old code. function old new delta arith_apply 990 1023 +33 evaluate_string 1467 1494 +27 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 60/0) Total: 60 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: decrease stack usageDenys Vlasenko2023-06-181-35/+27
| | | | | | | | | | | | | | function old new delta evaluate_string 1412 1467 +55 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: move varcmp() to shell_common.h and use it in hushDenys Vlasenko2023-06-174-50/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta unset_local_var - 112 +112 findvar 31 35 +4 set_vars_and_save_old 144 141 -3 helper_export_local 235 230 -5 set_local_var 425 416 -9 handle_changed_special_names 38 27 -11 builtin_unset 154 141 -13 builtin_getopts 404 391 -13 get_local_var_value 281 260 -21 get_ptr_to_local_var 71 45 -26 unset_local_var_len 139 - -139 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 1/8 up/down: 116/-240) Total: -124 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: code shrinkDenys Vlasenko2023-06-171-1/+1
| | | | | | | | | | | | | | function old new delta setvar 166 164 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/read: do not allow empty variable nameDenys Vlasenko2023-06-171-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: eliminate some redundant stores on return code pathDenys Vlasenko2023-06-171-20/+23
| | | | | | | | | | | | | | function old new delta evaluate_string 1432 1412 -20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: change ?: nesting code to not have 63 level nesting limitationDenys Vlasenko2023-06-172-14/+21
| | | | | | | | | | | | | | | | | | | | | | function old new delta evaluate_string 1406 1432 +26 arith 36 29 -7 arith_apply 998 990 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 26/-15) Total: 11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math.h: update comments, rearrange struct members for smaller codeDenys Vlasenko2023-06-172-23/+5
| | | | | | | | | | | | | | | | | | | | function old new delta arith_apply 1000 998 -2 evaluate_string 1414 1406 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-10) Total: -10 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: code shrinkDenys Vlasenko2023-06-171-3/+3
| | | | | | | | | | | | | | function old new delta evaluate_string 1432 1414 -18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: tweka commentsDenys Vlasenko2023-06-161-16/+8
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: fix ?: to not evaluate not-taken branchesDenys Vlasenko2023-06-1626-24/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | 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: simplify handling of unary plusDenys Vlasenko2023-06-151-3/+5
| | | | | | | | | | | | | | | | | | | | function old new delta evaluate_string 1257 1271 +14 arith_apply 977 968 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 14/-9) Total: 5 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: explain the logic, small tweak to make code smallerDenys Vlasenko2023-06-151-10/+25
| | | | | | | | | | | | | | function old new delta evaluate_string 1258 1257 -1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: fix order of expansion of variables to numbersDenys Vlasenko2023-06-153-34/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | 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: document another arithmetic discrepancy with bashDenys Vlasenko2023-06-152-0/+11
| | | | | | | | 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-155-9/+9
| | | | | | | | | | | | | | | | | | | | | | 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-1511-26/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/math: simpler insertion of "fake" last RPARENDenys Vlasenko2023-06-151-7/+6
| | | | | | | | | | | | | | | | | | Skip one pass through token table, since we know the result. function old new delta evaluate_string 1095 1097 +2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: sync ash/hush test scriptsDenys Vlasenko2023-06-142-8/+25
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: trivial code shrinkDenys Vlasenko2023-06-141-4/+3
| | | | | | | | | | | | | | function old new delta arith_apply 1143 1132 -11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: fix the order of variable resolution in binopsDenys Vlasenko2023-06-149-12/+48
| | | | | | | | | | | | | | function old new delta arith_apply 1134 1143 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: remove now-unused second_valDenys Vlasenko2023-06-141-20/+3
| | | | | | | | | | | | | | | | | | | | | | function old new delta arith_apply 1137 1134 -3 evaluate_string 1101 1095 -6 arith_lookup_val 150 143 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-16) Total: -16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: fix nested ?: and do not parse variables in not-taken branchDenys Vlasenko2023-06-147-43/+61
| | | | | | | | | | | | | | | | | | | | | | | | Fixes arith-ternary1.tests and arith-ternary_nested.tests function old new delta evaluate_string 1043 1101 +58 arith_apply 1087 1137 +50 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 108/0) Total: 108 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: remove a redundant checkDenys Vlasenko2023-06-141-6/+6
| | | | | | | | | | | | | | function old new delta arith_apply 1134 1087 -47 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: document ternary ?: op's weirdness, add code commentsDenys Vlasenko2023-06-143-28/+65
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: fix one name check, other minor cleanupsDenys Vlasenko2023-06-131-8/+12
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: add a few yet-failing arithmentic testsDenys Vlasenko2023-06-1310-0/+43
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell/math: reduce stack usageDenys Vlasenko2023-06-131-30/+36
| | | | | | | | | | | | | | | | | | | | | | function old new delta arith_apply 1123 1134 +11 arith_lookup_val 140 145 +5 evaluate_string 1053 1047 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 16/-6) Total: 10 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: avoid segfault on ${0::0/0~09J}. Closes 15216Denys Vlasenko2023-06-121-4/+35
| | | | | | | | | | | | | | function old new delta evaluate_string 1011 1053 +42 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix expansion of space in "a=${a:+$a }c" constructDenys Vlasenko2023-06-125-1/+17
| | | | | | | | | | | | | | function old new delta encode_then_append_var_plusminus 554 552 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: fix 'read' shell built-in (1)Ron Yorston2023-07-121-16/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider this test case: { echo -n te; sleep 3; echo st; } | (read -t 1 x; echo "$x") - bash echoes "te" after 1 second. - Upstream BusyBox echoes an empty "$x" after 1 second. - busybox-w32 echoes an empty "$x" after 3 seconds. The delayed echo in busybox-w32 arises because the 'read' shell built-in omits the code to poll for input. Rearrange the code so that polling takes place. This doesn't address the difference between BusyBox and bash. Costs 48-64 bytes.
* | ash: properly echo console input to 'read' built-inRon Yorston2023-07-122-4/+4
| | | | | | | | | | | | | | The 'read' shell built-in echoed console input to stdout. Echo directly to the console instead. Costs 124-136 bytes.
* | ash: standardise treatment of winxp optionRon Yorston2023-06-211-13/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although 'winxp' is a shell option it could only be set with '-X' on the command line. Fully implement 'winxp' so it can also be set within the shell by 'set -o winxp' and 'set +o winxp'. '-X' no longer needs to be the first option on the command line. Track which shell variables have been imported from a native Windows environment so only those are affected when 'winxp' is changed. The tracking persists in a subshell but is lost when shell variables are exported to the environment so 'set -/+o winxp' is ineffective in a child shell. Costs 48-52 bytes. (GitHub issue #322)
* | ash: code shrinkRon Yorston2023-06-211-28/+20
| | | | | | | | | | | | | | | | | | | | - There's no need to set USER, LOGNAME, HOME and SHELL as environment variables: making them shell variables is enough. - Use endofname() to detect invalid characters in variable names and take the copy of the invalid variable before it's modified. Saves 48-64 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2023-06-169-8/+63
|\|
| * hush: make "false" built-inDenys Vlasenko2023-05-251-0/+7
| | | | | | | | | | | | | | | | | | | | function old new delta bltins1 384 396 +12 builtin_false - 6 +6 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 18/0) Total: 18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix ELIF cmd1;cmd2 THEN ... not executing cmd2, closes 15571Denys Vlasenko2023-05-259-8/+56
| | | | | | | | | | | | | | function old new delta run_list 1012 1024 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: remove special treatment of USERNAMERon Yorston2023-06-051-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit 255ebaf535 (drop: adjust environment on privilege change) added USERNAME to the variables subject to special treatment when the shell starts or privilege is dropped. It's been pointed out this may not be appropriate for a variable that's Windows-specific. Remove the special treatment of USERNAME. Saves 40-48 bytes. (GitHub issue #300)
* | win32: code shrink applet look-upRon Yorston2023-06-051-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove find_preferred_applet_by_name(). Instead add a reference to is_applet_preferred() in find_applet_by_name(). - Remove the global variable ash_path. Use a static instead, accessed by calling get_ash_path(). - Mark ash_applet_by_name() as NOINLINE. Saves 64-96 bytes. (GitHub issue #329)
* | ash: fix build with line editing disabledRon Yorston2023-06-041-0/+4
| | | | | | | | | | | | | | | | | | Commit 64c8f5f3d0 (ash: add support for INT trap) made some changes to the line editing code. As a result building the shell with line editing disabled fails. Add the necessary conditional compilation to restore the ability to do this.
* | win32: another BB_OVERRIDE_APPLETS fixRon Yorston2023-06-041-5/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support for conditionally replacing applets with external commands requires the ability to check whether a given command name is present on PATH. This was being done using the PATH environment variable, which works in commands run by the shell but not in the shell itself. - The shell uses the *shell* variable PATH to look for executables. This may not be the same as the *environment* variable. - 'command -p' uses an entirely different PATH. Applet look-up in the shell is now treated as a special case, with the actual PATH being used passed to the look-up code in a global variable. This doesn't affect tab completion in the shell: whether a completion is an applet or an external command is irrelevant. Costs 152-288 bytes. (GitHub issue #329)
* | win32: fix BB_OVERRIDE_APPLETSRon Yorston2023-06-031-0/+8
| | | | | | | | | | | | | | | | | | | | | | Now that BB_OVERRIDE_APPLETS can affect how the shell searches PATH it may be necessary to invalidate the command table when it changes. It's probably not worth being clever about this: just invalidate the cache on every change. Adds 40-80 bytes (GitHub issue #329)
* | ash: enable 'set -/+o noconsole'Ron Yorston2023-06-011-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the 'noconsole' shell option could only be set as a shell command line option. Allow it to be changed from within the shell by 'set -o noconsole' or 'set +o noconsole'. The console window is now minimised rather than hidden. This makes it easier for the user to access the console when 'noconsole' is in effect. Adds 8-32 bytes. (GitHub issue #325)
* | Merge branch 'busybox' into mergeRon Yorston2023-05-232-0/+11
|\|