aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* hush: fix dot builtin to not search current directoryDenys Vlasenko2018-01-271-0/+5
| | | | | | | function old new delta builtin_source 182 209 +27 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix two corner cases in ${v/pattern/repl}. Closes 10686Denys Vlasenko2018-01-251-2/+11
| | | | | | | function old new delta expand_one_var 1592 1618 +26 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix handling of $_ (so far it's an ordinary variable, no special meaning)Denys Vlasenko2018-01-251-10/+17
| | | | | | | function old new delta parse_dollar 820 779 -41 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix a case where EXIT trap may modify its code mid-flightDenys Vlasenko2018-01-191-1/+1
| | | | | | | function old new delta hush_exit 93 99 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix build if !BASH_LINENO_VARDenys Vlasenko2018-01-191-8/+13
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: implement $LINENO bashismDenys Vlasenko2018-01-191-2/+54
| | | | | | | | | | | | | | | | function old new delta run_pipe 1697 1774 +77 unset_local_var_len 258 301 +43 hush_main 1009 1051 +42 set_local_var 516 554 +38 parse_and_run_file 42 75 +33 i_getch 96 116 +20 .rodata 18858 18876 +18 done_command 106 122 +16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 8/0 up/down: 287/0) Total: 287 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix raw ^C handlisg in single-quoted stringsDenys Vlasenko2018-01-131-0/+5
| | | | | | | function old new delta parse_stream 2719 2754 +35 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: tweak command -vV printing code, no logic changesDenys Vlasenko2018-01-121-3/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: implement "command -v -V"Denys Vlasenko2018-01-121-31/+84
| | | | | | | | | | | function old new delta pseudo_exec_argv 231 374 +143 if_command_vV_print_and_exit - 127 +127 builtin_set 267 273 +6 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 276/0) Total: 276 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: implement "command" builtin (no options are supported yet)Denys Vlasenko2018-01-111-1/+16
| | | | | | | function old new delta pseudo_exec_argv 194 231 +37 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix handling of ^C in evalDenys Vlasenko2018-01-111-4/+26
| | | | | | | | | | | function old new delta run_list 1044 1259 +215 builtin_eval 45 126 +81 expand_strvec_to_string 91 - -91 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 2/0 up/down: 296/-91) Total: 205 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix handling of raw ^C in scripts: "echo ^C"Denys Vlasenko2018-01-111-4/+19
| | | | | | | | function old new delta expand_vars_to_list 1133 1187 +54 parse_stream 2690 2719 +29 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: remove dead codeDenys Vlasenko2018-01-111-15/+0
| | | | | | | function old new delta done_word 761 711 -50 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* randomconfig fixesDenys Vlasenko2017-12-311-5/+8
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix comment parsing in `cmd`, closes 10421Denys Vlasenko2017-10-221-4/+13
| | | | | | | function old new delta parse_stream 2692 2690 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: GETOPT_RESET() _after_ getopts too.Denys Vlasenko2017-08-291-1/+2
| | | | | | | | | 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-291-15/+63
| | | | | | | | | | | | | | | | 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>
* 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,hush: comment and debug tweaks, no code changesDenys Vlasenko2017-08-151-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: implement "silent" optstrings of ":opts"Denys Vlasenko2017-08-111-17/+31
| | | | 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-111-5/+14
| | | | | | ash fails this! Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: teach getopts to set/unset OPTARGDenys Vlasenko2017-08-111-5/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: getopts builtinDenys Vlasenko2017-08-111-2/+75
| | | | | | | | | | 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>
* hush: optional times builtinDenys Vlasenko2017-08-101-2/+48
| | | | | | | | | | | 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>
* 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>
* noexec: consolidate codeDenys Vlasenko2017-08-071-7/+1
| | | | | | | | | | | | | 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-071-1/+2
| | | | | | | | | | 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-071-1/+4
| | | | | | | | | | | | 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-071-0/+2
| | | | | | pkill/pgrep/pidof uncovered another quirk: what about noexec's _process names_? Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sheel: improve comments on signal handlingDenys Vlasenko2017-08-041-0/+7
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: do not accept "if() { echo; }" function defDenys Vlasenko2017-08-021-17/+36
| | | | | | | | | | | | | | 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-021-2/+1
| | | | | | | | | | | | | | | | | | 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>
* hush: make SIGINT handling visually less confusingDenys Vlasenko2017-08-021-3/+3
| | | | | | | | | | | | | | | | | | | | | $ echo $$ 18448 $ echo $? <wait here, run "kill -INT 18448" in other shell><press enter> <=== NOTHING?? $ That empty line does not look right. After this patch: $ echo $$ 18448 $ echo $? <wait here, run "kill -INT 18448" in other shell><press enter> ^C $ function old new delta fgetc_interactive 245 246 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* NOFORK fixesDenys Vlasenko2017-08-021-1/+30
| | | | | | | | | | | | | | | | | | "rm -i FILE" and "yes" can now be interrupted by ^C in hush. This also now works: $ usleep 19999999 ^C $ echo $? 130 function old new delta run_pipe 1668 1711 +43 pseudo_exec_argv 312 321 +9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 52/0) Total: 52 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: remove redundant "G_flag_return_in_progress = -1"Denys Vlasenko2017-07-311-1/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix "true | func_with_return" not allowing return.Denys Vlasenko2017-07-311-8/+36
| | | | | | | function old new delta pseudo_exec_argv 305 312 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: functions have priority over builtins (!)Denys Vlasenko2017-07-311-14/+19
| | | | | | | | | | function old new delta pseudo_exec_argv 291 305 +14 run_pipe 1560 1555 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 14/-5) Total: 9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: if STANDALONE, close interactive fd for NOEXECed childrenDenys Vlasenko2017-07-311-2/+15
| | | | | | | function old new delta pseudo_exec_argv 291 305 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash,hush: ">&10" redirects to script/tty fds should not workDenys Vlasenko2017-07-311-10/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | The fact that shell has open fds to tty and/or scripts should be unobservable, if possible. In particular, if redirect tries to dup one of them via ">&script_fd", it's better to pretend that script_fd is closed, and thus redirect fails with EBADF. Fixes these two testcase failures: ash-redir/redir_to_bad_fd.tests hush-redir/redir_to_bad_fd3.tests function old new delta redirect 1018 1129 +111 setup_redirects 250 359 +109 readtoken1 2651 2655 +4 cmdloop 185 187 +2 changepath 194 195 +1 save_fd_on_redirect 203 194 -9 evaltree 501 484 -17 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/2 up/down: 227/-26) Total: 201 bytes text data bss dec hex filename 914553 485 6848 921886 e111e busybox_old 914754 485 6848 922087 e11e7 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: massage redirect code to be slightly more like ashDenys Vlasenko2017-07-311-37/+72
| | | | | | | | | | | | | function old new delta save_fd_on_redirect - 203 +203 xdup_CLOEXEC_and_close - 75 +75 setup_redirects 245 250 +5 xdup_and_close 72 - -72 save_fds_on_redirect 221 - -221 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 1/0 up/down: 283/-293) Total: -10 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix handling of empty heredoc EOF markerDenys Vlasenko2017-07-291-17/+27
| | | | | | | function old new delta parse_stream 2609 2634 +25 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix ${##}, ${#?}, ${#!} handlingDenys Vlasenko2017-07-261-7/+20
| | | | | | | | | | function old new delta parse_dollar 786 820 +34 expand_one_var 1579 1592 +13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 47/0) Total: 47 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: allow "trap NUM [SIG]..." syntaxDenys Vlasenko2017-07-251-1/+1
| | | | | | | | | | | | | While at it, make get_signum() return -1 for numeric strings >= NSIG. function old new delta trapcmd 292 306 +14 get_signum 295 300 +5 builtin_trap 413 412 -1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 19/-1) Total: 18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: treat ${#?} as "length of $?"Denys Vlasenko2017-07-251-3/+9
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix a case when redirect to a closed fd #1 is not restoring (closing) itDenys Vlasenko2017-07-241-7/+27
| | | | | | | | | | | function old new delta setup_redirects 200 245 +45 append_squirrel - 41 +41 save_fds_on_redirect 256 221 -35 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 86/-35) Total: 51 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: use mempcpy where usefulDenys Vlasenko2017-07-241-7/+4
| | | | | | | | | | function old new delta o_addblock 58 42 -16 expand_one_var 1618 1555 -63 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-79) Total: -79 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* config: deindent all help textsDenys Vlasenko2017-07-211-27/+27
| | | | | | Those two spaces after tab have no effect, and always a nuisance when editing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: remove contradicting size info in config helpDenys Vlasenko2017-07-181-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>