aboutsummaryrefslogtreecommitdiff
path: root/shell (follow)
Commit message (Collapse)AuthorAgeFilesLines
* ash: fail if 'shift' operand is out of rangeIngo van Lil2018-02-141-1/+1
| | | | | | | | | | | | | | | | If the numeric argument passed to ash's 'shift' built-in is greater than '$#' the command performs no operation and exits successfully. It should return a non-zero exit code instead: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#shift This is consistent with bash and hush. function old new delta shiftcmd 122 120 -2 Signed-off-by: Ingo van Lil <inguin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* randomconfig fixesDenys Vlasenko2017-12-312-6/+9
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix nofork bug where environment is not properly passed to a commandDenys Vlasenko2017-11-035-5/+88
| | | | | | | | | | | | function old new delta listvars 144 252 +108 evalcommand 1500 1546 +46 showvars 142 147 +5 shellexec 242 245 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 162/0) Total: 162 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: retain envvars with bad names in initial environment. Closes 10231Denys Vlasenko2017-11-021-4/+22
| | | | | | | Reworks "ash: [VAR] Sanitise environment variable names on entry" commit. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix comment parsing in `cmd`, closes 10421Denys Vlasenko2017-10-225-4/+47
| | | | | | | function old new delta parse_stream 2692 2690 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* whitespace fixesDenys Vlasenko2017-10-121-3/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* typo fixDenys Vlasenko2017-10-121-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: survive failures in $PS1 expansion. Closes 10371Denys Vlasenko2017-10-121-1/+18
| | | | | | | function old new delta expandstr 120 209 +89 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* use %m printf specifier where appropriateDenys Vlasenko2017-09-291-8/+1
| | | | | | | | | | | | | | | function old new delta out 85 75 -10 udhcpd_main 1472 1461 -11 open_stdio_to_tty 98 85 -13 init_exec 245 232 -13 udhcpc_main 2763 2749 -14 do_cmd 4771 4755 -16 status_line_bold_errno 32 14 -18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-95) Total: -95 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* regularize format of source file headers, no code changesDenys Vlasenko2017-09-181-6/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix false positive in unset.testsDenys Vlasenko2017-08-291-0/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: GETOPT_RESET() _after_ getopts too.Denys Vlasenko2017-08-292-3/+4
| | | | | | | | | NOEXEC'ed applets which use getopt() need this. function old new delta builtin_getopts 403 413 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: reuse "OPTIND=..." stringDenys Vlasenko2017-08-291-1/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix "getopts" builtin to not be upset by other builtins calling getopt()Denys Vlasenko2017-08-295-15/+133
| | | | | | | | | | | | | | | | function old new delta builtin_getopts 363 403 +40 unset_local_var_len 185 215 +30 set_local_var 440 466 +26 reset_traps_to_defaults 151 157 +6 pseudo_exec_argv 320 326 +6 install_special_sighandlers 52 58 +6 pick_sighandler 62 65 +3 execvp_or_die 85 88 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 8/0 up/down: 120/0) Total: 120 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: more s/error/perror/ for better error reportingDenys Vlasenko2017-08-231-5/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: when cd fails, say whyJohannes Schindelin2017-08-231-1/+1
| | | | | Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: report reason when a script file could not be openedJohannes Schindelin2017-08-231-1/+1
| | | | | | | | It is always nicer to give the user some sort of indication why an operation failed. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: stage backported LINENO support as a separate patchDenys Vlasenko2017-08-171-0/+498
| | | | | | | | Looks biggish and not particularly useful, but may be easier to just eat the impact if future backports from dash would be otherwise increasingly difficult. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: trivial code shrink in builtin_getoptsDenys Vlasenko2017-08-171-4/+5
| | | | | | | function old new delta builtin_getopts 368 363 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: unset OPTARG if getopts exits 1, support OPTERR=0 behaviorDenys Vlasenko2017-08-151-2/+11
| | | | | | | function old new delta getoptscmd 522 547 +25 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash,hush: comment and debug tweaks, no code changesDenys Vlasenko2017-08-152-3/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: one "current line = 1" might be missing, fix thatDenys Vlasenko2017-08-141-4/+5
| | | | | | | I'm not sure this is necessary, but dash has this init here. Just in case, do it too. 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>
* ash: [PARSER] Catch variable length expansions on non-existant specialsDenys Vlasenko2017-08-141-3/+9
| | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 30 Oct 2014 11:53:35 +0800 [PARSER] Catch variable length expansions on non-existant specials Currently we only check special variable names that follow directly after $ or ${. So errors such as ${#&} are not caught. This patch fixes that by moving the is_special check to just before we print out the special variable name. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta readtoken1 2630 2635 +5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: tweak getopts tests, no code changesDenys Vlasenko2017-08-136-4/+34
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: implement "silent" optstrings of ":opts"Denys Vlasenko2017-08-115-17/+89
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: add a test which fails due to uclibc bug in getopt()Denys Vlasenko2017-08-114-0/+128
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix redirect code (was using uninitialized variables)Denys Vlasenko2017-08-111-2/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: add OPTARG poisoning to getopt_optarg.testsDenys Vlasenko2017-08-113-5/+18
| | | | | | ash fails this! Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: teach getopts to set/unset OPTARGDenys Vlasenko2017-08-116-6/+73
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: getopts builtinDenys Vlasenko2017-08-117-2/+212
| | | | | | | | | | function old new delta builtin_getopts - 271 +271 bltins1 372 384 +12 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 283/0) Total: 283 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix "unset OPTIND" throwing an error messageDenys Vlasenko2017-08-113-1/+112
| | | | | | | Added test was failing quite severely. Now only one subtest fails (OPTERR=0 has no effect). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: optional times builtinDenys Vlasenko2017-08-102-9/+57
| | | | | | | | | | | function old new delta builtin_times - 108 +108 bltins1 360 372 +12 static.times_tbl - 9 +9 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 1/0 up/down: 129/0) Total: 129 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: more efficient check for EOL in readDenys Vlasenko2017-08-092-4/+8
| | | | | | | function old new delta shell_builtin_read 1334 1320 -14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: implement -d DELIM option for 'read'Denys Vlasenko2017-08-091-2/+11
| | | | | | | | | | | | | | | | | | | The POSIX standard only requires the 'read' builtin to handle '-r': http://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html However, Bash introduced the option '-d <DELIM>' to override IFS for just one invocation, and it is quite useful. We already support this in ash, let's add it to hush, too. function old new delta builtin_read 263 284 +21 .rodata 163587 163589 +2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 23/0) Total: 23 bytes Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: implement -d DELIM option for readJohannes Schindelin2017-08-093-7/+21
| | | | | | | | | | | | | | | | | | | | | | | The POSIX standard only requires the read builtin to handle -r: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html However, Bash introduced the option -d <DELIM> to override IFS for just one invocation, and it is quite useful. It is also super easy to implement in BusyBox' ash, so let's do that. The motivation: This option is used by Git's test suite. function old new delta .rodata 163505 163587 +82 shell_builtin_read 1244 1289 +45 readcmd 233 259 +26 builtin_read 258 263 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 158/0) Total: 158 bytes Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* noexec: consolidate codeDenys Vlasenko2017-08-072-14/+2
| | | | | | | | | | | | | function old new delta run_noexec_applet_and_exit - 61 +61 find_applet_by_name 128 124 -4 run_applet_no_and_exit 441 434 -7 tryexec 169 152 -17 pseudo_exec_argv 338 321 -17 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/6 up/down: 61/-48) Total: 13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* noexec: do GETOPT_RESET() before entering APPLET_main()Denys Vlasenko2017-08-072-1/+3
| | | | | | | | | | hush -c 'yes | head -1' was not happy. function old new delta tryexec 159 169 +10 pseudo_exec_argv 328 338 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* noexec: set comm field for noexecsDenys Vlasenko2017-08-072-2/+8
| | | | | | | | | | | | function old new delta set_task_comm - 18 +18 tryexec 152 159 +7 pseudo_exec_argv 321 328 +7 main 106 97 -9 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/2 up/down: 34/-13) Total: 23 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* free,stat: make NOEXECDenys Vlasenko2017-08-072-0/+4
| | | | | | pkill/pgrep/pidof uncovered another quirk: what about noexec's _process names_? Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: do not set a signal to SIG_DFL if it already isDenys Vlasenko2017-08-061-1/+7
| | | | | | | function old new delta setsignal 312 338 +26 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* make 17 state-changing execing applets (ex: "nice PROG ARGS") noexecDenys Vlasenko2017-08-041-1/+1
| | | | | | | | | | | | | | | | | | | | The applets with "<applet> [opts] PROG ARGS" API very quickly exec another program, noexec is okay for them: chpst/envdir/envuidgid/softlimit/setuidgid chroot chrt ionice nice nohup setarch/linux32/linux64 taskset cttyhack "reset" and "sulogin" applets don't have this form, but also exec another program at once, thus made noexec too. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: BASH_XTRACEFD bashismDenys Vlasenko2017-08-041-0/+10
| | | | | | | | | Based on patch by Johannes Schindelin <johannes.schindelin@gmx.de> function old new delta evalcommand 1447 1500 +53 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: remove no-longer-used variableJohannes Schindelin2017-08-041-2/+0
| | | | | | | | | | | As of 035486c75 (ash: significant overhaul of redirect saving logic, 2017-07-31), the sv_pos variable is no longer used (just assigned to, with no further effect). Let's just remove it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: INT_OFF/INT_ON around run_nofork_applet()Denys Vlasenko2017-08-041-3/+19
| | | | | | | function old new delta evalcommand 1441 1447 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sheel: improve comments on signal handlingDenys Vlasenko2017-08-042-11/+23
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: add a fixme comment at run_nofork_appletDenys Vlasenko2017-08-031-1/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* nofork: fix a bug uncovered by hush testsuite (forgotten fflush)Denys Vlasenko2017-08-031-1/+1
| | | | | | | function old new delta run_nofork_applet 280 287 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: do not accept "if() { echo; }" function defDenys Vlasenko2017-08-025-17/+60
| | | | | | | | | | | | | | function old new delta parse_stream 2634 2692 +58 msg_and_die_if_script - 21 +21 syntax_error_unexpected_ch 41 46 +5 syntax_error_at 14 18 +4 die_if_script 31 28 -3 setup_redirects 319 308 -11 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/2 up/down: 88/-14) Total: 74 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* line editing: make read_line_input() not take timeout paramDenys Vlasenko2017-08-022-4/+4
| | | | | | | | | | | | | | | | | | It's almost always -1. function old new delta read_line_input 3902 3912 +10 new_line_input_t 24 31 +7 pgetc 583 585 +2 save_command_ps_at_cur_history 80 78 -2 read_line 76 74 -2 fgetc_interactive 246 244 -2 addLines 84 82 -2 doCommands 2226 2222 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/5 up/down: 19/-12) Total: 7 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>