summaryrefslogtreecommitdiff
path: root/shell/hush.c
AgeCommit message (Collapse)Author
2022-06-26ash,hush: use HOME for tab completion and promptsRon Yorston
ash and hush correctly use the value of HOME for tilde expansion. However the line editing code in libbb obtains the user's home directory by calling getpwuid(). Thus tildes in tab completion and prompts may be interpreted differently than in tilde expansion. When the line editing code is invoked from a shell make it use the shell's interpretation of tilde. This is similar to how GNU readline and bash collaborate. function old new delta get_homedir_or_NULL 29 72 +43 optschanged 119 126 +7 hush_main 1204 1211 +7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 57/0) Total: 57 bytes v2: Always check for HOME before trying the password database: this is what GNU readline does. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-02-06*: slap on a few ALIGN_PTR where appropriateDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-17ash,hush: fix handling of SIGINT while waiting for interactive inputDenys Vlasenko
function old new delta lineedit_read_key 160 237 +77 __pgetc 522 589 +67 fgetc_interactive 244 309 +65 safe_read_key - 39 +39 read_key 588 607 +19 record_pending_signo 23 32 +9 signal_handler 75 81 +6 .rodata 104312 104309 -3 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 6/1 up/down: 282/-3) Total: 279 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-13libbb: invert the meaning of SETUP_ENV_NO_CHDIR -> SETUP_ENV_CHDIRDenys Vlasenko
Double negatives are hard to grok. function old new delta login_main 986 988 +2 su_main 474 470 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 2/-4) Total: -2 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-05libbb: code shrink: introduce and use [_]exit_SUCCESS()Denys Vlasenko
function old new delta exit_SUCCESS - 7 +7 _exit_SUCCESS - 7 +7 run_pipe 1562 1567 +5 pseudo_exec_argv 399 400 +1 finish 86 87 +1 start_stop_daemon_main 1109 1107 -2 shutdown_on_signal 38 36 -2 runsv_main 1662 1660 -2 redirect 1070 1068 -2 read_line 79 77 -2 pause_and_low_level_reboot 54 52 -2 list_i2c_busses_and_exit 483 481 -2 less_exit 12 10 -2 identify 4123 4121 -2 grep_file 1161 1159 -2 getty_main 1519 1517 -2 fsck_minix_main 2681 2679 -2 free_session 132 130 -2 fdisk_main 4739 4737 -2 clean_up_and_exit 53 51 -2 bsd_select 1566 1564 -2 bb_daemonize_or_rexec 198 196 -2 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 3/17 up/down: 21/-34) Total: -13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-13shell: tweak --helpDenys Vlasenko
Even though formally it is -s [ARGS], "sh -s" without ARGS is the same as just "sh". And we are already over 80 chars wide for ash --help, so make it shorter. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-13hush: in a comment, document what -i might be doingDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-12shell: use more compact SHELL_ASH / HUSH config defines. no code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-10*: add NOINLINEs where code noticeably shrinksDenys Vlasenko
function old new delta display 85 1463 +1378 -73 bytes select_and_cluster - 1088 +1088 -139 bytes parse_reply - 979 +979 -109 bytes zbc_num_sqrt - 632 +632 -191 bytes show_bridge_port - 585 +585 -56 bytes sp_256_proj_point_add_8 - 576 +576 -45 bytes encode_then_append_var_plusminus - 554 +554 -118 bytes read_mode_db - 537 +537 -47 bytes fbset_main 1331 747 -584 sp_256_ecc_mulmod_8 1157 536 -621 brctl_main 2189 1548 -641 expand_one_var 2544 1872 -672 zxc_vm_process 6412 5589 -823 send_queries 1813 725 -1088 recv_and_process_peer_pkt 2245 1018 -1227 bb_dump_dump 1531 80 -1451 ------------------------------------------------------------------------------ (add/remove: 7/0 grow/shrink: 1/8 up/down: 6329/-7107) Total: -778 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-09hush: speed up ${x//\*/|} tooDenys Vlasenko
function old new delta expand_one_var 2502 2544 +42 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-07hush: fix var_LINENO3.tests failureDenys Vlasenko
function old new delta parse_and_run_string 40 62 +22 i_getch 105 102 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 22/-3) Total: 19 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-07hush: fix set -n to act immediately, not just after run_list()Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-15hush: fix "error: invalid preprocessing directive ##"Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-27hush: tweak ${var/pattern/repl} optimizationDenys Vlasenko
function old new delta expand_one_var 2507 2502 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-27hush: optimize ${var/pattern/repl} for trivial patternsDenys Vlasenko
function old new delta expand_one_var 2353 2507 +154 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-27hush: add missed "undef"Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-26hush: implement $'str' bashismDenys Vlasenko
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>
2021-06-19hush: fix bkslash+newline handling and number validation in ${NN} and ${#NN}Denys Vlasenko
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>
2021-06-15hush: fix handling of "cmd && &"Denys Vlasenko
function old new delta done_pipe 213 231 +18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-15hush: fix handling of \^C and "^C"Denys Vlasenko
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>
2021-06-15*: more --help tweaksDenys Vlasenko
function old new delta packed_usage 33552 33541 -11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-14*: --help tweaksDenys Vlasenko
function old new delta packed_usage 33589 33552 -37 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-06shells: do not allow bare "read" in non-bash compat configsDenys Vlasenko
On Sat, Feb 9, 2019 Cristian Ionescu-Idbohrn wrote: > In my case (at work), I have to watch and prevent people from doing > unportable things. For me, that's a burden. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-13hush: beautify ^D handling to match ash / bashDenys Vlasenko
function old new delta fgetc_interactive 227 244 +17 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-10hush: make LINENO selectable without BASH-COMPATDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-03libbb: introduce and use fputs_stdoutRon Yorston
function old new delta fputs_stdout - 12 +12 zxc_vm_process 7237 7230 -7 yes_main 85 78 -7 write_block 380 373 -7 wrapf 305 298 -7 strings_main 437 430 -7 show_bridge 353 346 -7 rev_main 384 377 -7 put_prompt_custom 58 51 -7 put_cur_glyph_and_inc_cursor 168 161 -7 print_numbered_lines 152 145 -7 print_named_ascii 130 123 -7 print_name 135 128 -7 print_login_issue 386 379 -7 print_ascii 208 201 -7 powertop_main 1249 1242 -7 od_main 1789 1782 -7 logread_main 518 511 -7 head_main 804 797 -7 display_process_list 1319 1312 -7 cut_main 1002 995 -7 bb_dump_dump 1550 1543 -7 bb_ask_noecho 393 386 -7 baseNUM_main 702 695 -7 expand_main 755 745 -10 dumpleases_main 497 487 -10 write1 12 - -12 putcsi 37 23 -14 print_login_prompt 55 41 -14 paste_main 525 511 -14 cat_main 440 426 -14 print_it 245 230 -15 print_addrinfo 1188 1171 -17 print_rule 770 750 -20 print_linkinfo 842 822 -20 httpd_main 791 771 -20 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 0/34 up/down: 12/-341) Total: -329 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-01-04hush: code shrinkDenys Vlasenko
function old new delta hush_main 1071 1066 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5) Total: -5 bytes text data bss dec hex filename 1020110 559 5020 1025689 fa699 busybox_old 1020037 559 5020 1025616 fa650 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-30libbb: introduce and use xgettimeofday(), do not truncate 64-bit time_t in ↵Denys Vlasenko
shells function old new delta xgettimeofday - 11 +11 get_local_var_value 280 281 +1 svlogd_main 1323 1322 -1 change_epoch 67 66 -1 timestamp_and_log 461 458 -3 hwclock_main 301 298 -3 fmt_time_bernstein_25 135 132 -3 step_time 331 326 -5 script_main 1207 1202 -5 machtime 34 28 -6 curtime 61 54 -7 ts_main 423 415 -8 nmeter_main 761 751 -10 gettime1900d 67 46 -21 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/12 up/down: 12/-73) Total: -61 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-29randomconfig fixesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-27hush: make comment more clearDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-25hush: fix this case: echo "SCRIPT" | hushDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-25hush: if !EDITING, do not regenerate prompt for every input charDenys Vlasenko
function old new delta fgetc_interactive 261 258 -3 pseudo_exec_argv 406 399 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-10) Total: -10 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-23hush: fix ^C in INTERACTIVE, !EDITING configDenys Vlasenko
function old new delta refill_HFILE_and_getc 88 170 +82 fgetc_interactive 226 250 +24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 106/0) Total: 106 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-23hush: revert "make interactive ^C break out of PS2 mode"Denys Vlasenko
It made ^C break out of the entire shell, if we aren't in PS2 mode. Need a better idea. function old new delta expand_one_var 2344 2353 +9 syntax_error_unterm_ch 21 29 +8 parse_dollar 817 824 +7 parse_stream 2251 2238 -13 fgetc_interactive 249 227 -22 syntax_error_unterm_str 26 - -26 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 3/2 up/down: 24/-61) Total: -37 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-23hush: fix PS1 prompth in !EDITING configDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-23hush: fix fallout from tweaking ${var:START:LEN} codeDenys Vlasenko
function old new delta expand_one_var 2344 2353 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-23shell: for signal exitcode, use 128 | sig, not 128 + sig - MIPS has signal 128Denys Vlasenko
function old new delta wait_for_child_or_signal 213 214 +1 refill_HFILE_and_getc 89 88 -1 getstatus 97 96 -1 builtin_wait 339 337 -2 checkjobs 187 183 -4 process_wait_result 450 444 -6 waitcmd 290 281 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/6 up/down: 1/-23) Total: -22 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-23hush: fix commentDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-21bc: do not allocate line editing state until neededDenys Vlasenko
function old new delta xc_read_line 324 353 +29 free_line_input_t 34 39 +5 xc_vm_init 656 640 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 34/-16) Total: 18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-21hush: deal with FIXMEs for corner cases in parameter expansionDenys Vlasenko
function old new delta expand_one_var 2323 2344 +21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-20hush: remove one redundant getpid() on every startupDenys Vlasenko
function old new delta hush_main 1151 1147 -4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-14hush: code shrinkDenys Vlasenko
function old new delta run_applet_main - 20 +20 builtin_kill 296 288 -8 builtin_test 19 10 -9 builtin_printf 19 10 -9 builtin_echo 19 10 -9 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/4 up/down: 20/-35) Total: -15 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13hush: if login shell, also source ~/.profileDenys Vlasenko
function old new delta hush_main 1101 1151 +50 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13hush: NOMMU fix for hush-psubst/tick6.testsDenys Vlasenko
function old new delta hush_main 1759 1766 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13hush: fix -c SCRIPT handlingDenys Vlasenko
function old new delta hush_main 1763 1759 -4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-30decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nillyDenys Vlasenko
text data bss dec hex filename 1021988 559 5052 1027599 fae0f busybox_old 1021236 559 5052 1026847 fab1f busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-16hush: make interactive ^C break out of PS2 modeDenys Vlasenko
function old new delta syntax_error_unterm_str - 26 +26 parse_stream 2238 2251 +13 fgetc_interactive 243 249 +6 parse_dollar 824 817 -7 syntax_error_unterm_ch 29 21 -8 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/2 up/down: 45/-15) Total: 30 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-31shell: update comments on the status of [[ ]] compatDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-31shell: better support of [[ ]] bashismDenys Vlasenko
Still rather rudimentary for ash function old new delta binop 433 589 +156 check_operator 65 101 +36 done_word 736 769 +33 test_main 405 418 +13 parse_stream 2227 2238 +11 ops_texts 124 133 +9 ops_table 80 86 +6 run_pipe 1557 1562 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 8/0 up/down: 269/0) Total: 269 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-24hush: output bash-compat killing signal namesDenys Vlasenko
This significantly syncronises ash-signals and hush-signals tests. function old new delta process_wait_result 449 450 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>