Denys Vlasenko
f2cf1cc716
noexec: set comm field for noexecs
...
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>
2017-08-07 18:45:33 +02:00
Denys Vlasenko
248a67fb75
free,stat: make NOEXEC
...
pkill/pgrep/pidof uncovered another quirk: what about noexec's _process names_?
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-07 18:18:09 +02:00
Denys Vlasenko
49e6bf2db9
sheel: improve comments on signal handling
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-04 14:28:16 +02:00
Denys Vlasenko
39701204cf
hush: do not accept "if() { echo; }" function def
...
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>
2017-08-02 19:46:14 +02:00
Denys Vlasenko
84ea60ed65
line editing: make read_line_input() not take timeout param
...
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>
2017-08-02 17:27:28 +02:00
Denys Vlasenko
dd4b446f76
hush: make SIGINT handling visually less confusing
...
$ 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>
2017-08-02 16:52:12 +02:00
Denys Vlasenko
7c40ddd950
NOFORK fixes
...
"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>
2017-08-02 16:37:39 +02:00
Denys Vlasenko
cee603d921
hush: remove redundant "G_flag_return_in_progress = -1"
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-31 18:06:07 +02:00
Denys Vlasenko
5b3d2eb327
hush: fix "true | func_with_return" not allowing return.
...
function old new delta
pseudo_exec_argv 305 312 +7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-31 18:02:28 +02:00
Denys Vlasenko
75481d3634
hush: functions have priority over builtins (!)
...
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>
2017-07-31 05:27:09 +02:00
Denys Vlasenko
bf1c344dfd
hush: if STANDALONE, close interactive fd for NOEXECed children
...
function old new delta
pseudo_exec_argv 291 305 +14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-31 04:54:53 +02:00
Denys Vlasenko
32fdf2f9fc
ash,hush: ">&10" redirects to script/tty fds should not work
...
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>
2017-07-31 04:35:18 +02:00
Denys Vlasenko
657e9005a9
hush: massage redirect code to be slightly more like ash
...
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>
2017-07-31 04:08:09 +02:00
Denys Vlasenko
0f018b3070
hush: fix handling of empty heredoc EOF marker
...
function old new delta
parse_stream 2609 2634 +25
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-29 20:43:26 +02:00
Denys Vlasenko
2093ad296f
hush: fix ${##}, ${#?}, ${#!} handling
...
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>
2017-07-26 00:07:27 +02:00
Denys Vlasenko
86981e3ad2
ash: allow "trap NUM [SIG]..." syntax
...
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>
2017-07-25 20:06:17 +02:00
Denys Vlasenko
645c697372
hush: treat ${#?} as "length of $?"
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-25 15:18:57 +02:00
Denys Vlasenko
621fc50e83
hush: fix a case when redirect to a closed fd #1 is not restoring (closing) it
...
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>
2017-07-24 12:42:17 +02:00
Denys Vlasenko
0675b03de4
hush: use mempcpy where useful
...
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>
2017-07-24 02:17:05 +02:00
Denys Vlasenko
72089cf6b4
config: deindent all help texts
...
Those two spaces after tab have no effect, and always a nuisance when editing.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21 09:50:55 +02:00
Denys Vlasenko
f9d656f787
hush: remove contradicting size info in config help
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 22:23:55 +02:00
Denys Vlasenko
4eed2c6c50
Update menuconfig items with approximate applet sizes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 22:01:24 +02:00
Denys Vlasenko
d2c15bc763
hush: tweak "help" output
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 18:14:42 +02:00
Denys Vlasenko
cf5110978b
hush: fix readonly2.tests failure
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 15:58:02 +02:00
Denys Vlasenko
5b2cc0aaee
hush: do not assign to readonly VAR in "VAR=VAL CMD" syntax too
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 02:44:06 +02:00
Denys Vlasenko
38ef39a1ab
hush: add readonly testcase, fix fallout
...
function old new delta
helper_export_local 185 214 +29
run_pipe 1549 1560 +11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 40/0) Total: 40 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 01:40:01 +02:00
Denys Vlasenko
3bab36b18b
hush: convert exp/ro/local parameters to bitfields in one flag param
...
function old new delta
helper_export_local 174 185 +11
set_local_var 424 420 -4
run_list 1048 1044 -4
set_vars_and_save_old 88 83 -5
set_local_var_from_halves 27 22 -5
run_pipe 1554 1549 -5
builtin_export 173 168 -5
set_pwd_var 40 34 -6
builtin_readonly 70 64 -6
expand_one_var 1625 1618 -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/9 up/down: 11/-47) Total: -36 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 01:05:24 +02:00
Denys Vlasenko
6b0695bb66
hush: HUSH_READONLY depends on HUSH
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-17 21:47:27 +02:00
Denys Vlasenko
6b48e1f121
hush: forgot to emit error on (failing) second "readonly VAR=VAL"
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-17 21:31:17 +02:00
Denys Vlasenko
b95ee96e75
hush: smaller code in !READONLY configs
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-17 21:19:53 +02:00
Denys Vlasenko
1e660422b1
hush: implement "readonly" builtin
...
function old new delta
builtin_readonly - 70 +70
helper_export_local 152 174 +22
bltins1 348 360 +12
expand_one_var 1620 1625 +5
builtin_export 168 173 +5
set_pwd_var 36 40 +4
set_local_var 410 414 +4
set_vars_and_save_old 85 88 +3
set_local_var_from_halves 24 27 +3
run_pipe 1551 1554 +3
run_list 1046 1048 +2
builtin_type 116 114 -2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 10/1 up/down: 133/-2) Total: 131 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-17 21:10:50 +02:00
Denys Vlasenko
0ba80e4fa2
hush: small fix to last commit
...
die_if_script() indeed dies only in scripts! Must handle the case where it continues.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-17 16:50:20 +02:00
Denys Vlasenko
e32b6503e7
hush: support ${VAR:N:-M}
...
function old new delta
expand_one_var 1602 1615 +13
builtin_type 114 116 +2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-17 16:46:57 +02:00
Denys Vlasenko
203fd7bc66
shells: expand TODO comments, no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-17 16:13:35 +02:00
Denys Vlasenko
b24e55da84
hush: fix "cmd1 && cmd2 &" handling on NOMMU
...
function old new delta
done_pipe 234 238 +4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-16 20:29:35 +02:00
Denys Vlasenko
ee553b929c
hush: fix and_or_and_backgrounding.tests failure
...
function old new delta
done_pipe 133 218 +85
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-15 22:51:55 +02:00
Denys Vlasenko
2ed74e25d3
hush: make "wait %1" work even if the job is dead
...
Example script:
sleep 1 | (sleep 1;exit 3) &
sleep 2
echo Zero:$?
wait %1
echo Three:$?
function old new delta
clean_up_last_dead_job - 24 +24
process_wait_result 426 447 +21
builtin_wait 285 293 +8
insert_job_into_table 264 269 +5
builtin_jobs 68 73 +5
remove_job_from_table 59 57 -2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/1 up/down: 63/-2) Total: 61 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 19:58:46 +02:00
Denys Vlasenko
0c5657e911
hush: remove superfluous comparison
...
function old new delta
builtin_wait 291 285 -6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 19:27:03 +02:00
Denys Vlasenko
9fda609a60
hush: add support for "set -e"
...
function old new delta
run_list 978 1046 +68
o_opt_strings 24 32 +8
reset_traps_to_defaults 136 142 +6
pick_sighandler 57 60 +3
packed_usage 31772 31770 -2
hush_main 983 961 -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/2 up/down: 85/-24) Total: 61 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 13:36:48 +02:00
Denys Vlasenko
b057806a6a
hush: add TODO for "set -e"
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-10 10:33:27 +02:00
Denys Vlasenko
9e55a156f8
hush: simplify insert_job_into_table() a bit
...
function old new delta
done_word 767 761 -6
insert_job_into_table 325 264 -61
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 59/-126) Total: -67 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-10 10:01:12 +02:00
Denys Vlasenko
1609629a91
hush: rename a few functions
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-10 10:00:28 +02:00
Denys Vlasenko
13102634bb
hush: explain why wait5.tests is failing
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-08 00:24:32 +02:00
Denys Vlasenko
840a4355d0
hush: fix "(sleep 1; exit 3) & sleep 2; echo $?; wait $!; echo $?"
...
function old new delta
process_wait_result 414 426 +12
builtin_wait 283 291 +8
run_list 974 978 +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 24/0) Total: 24 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-07 22:56:02 +02:00
Denys Vlasenko
2db74610cd
hush: fix two redirection testcase failures
...
function old new delta
save_fds_on_redirect 183 256 +73
fcntl_F_DUPFD - 46 +46
restore_redirects 74 96 +22
xdup_and_close 51 72 +21
setup_redirects 196 200 +4
hush_main 988 983 -5
static.C 12 - -12
run_pipe 1595 1551 -44
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 4/2 up/down: 166/-61) Total: 105 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-07 22:07:28 +02:00
Denys Vlasenko
69a5ec9dcc
main: fix the case where user has "halt" as login shell. Closes 9986
...
halt::0:0::/:/sbin/halt
function old new delta
run_applet_and_exit 748 751 +3
run_applet_no_and_exit 467 459 -8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-07 19:08:56 +02:00
Denys Vlasenko
50b8b2914b
hush: add a TODO about redir3.tests failure
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-06 20:57:37 +02:00
Denys Vlasenko
e59591a364
hush: Print error messages on shift -1
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-06 20:12:44 +02:00
Denys Vlasenko
5dad7bdc3b
hush: implement negative start in the ${v: -n[:m]} idiom
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-06 19:48:20 +02:00
Denys Vlasenko
7456298472
hush: "adopt" ash signal4.tests
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-06 18:40:45 +02:00
Denys Vlasenko
637982f5bb
hush: correctly handle quoting in "case" even if !BASH_PATTERN_SUBST
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-06 01:52:23 +02:00
Denys Vlasenko
bd43c6784f
hush: fix quoted_punct.tests failure
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-05 23:12:15 +02:00
Denys Vlasenko
d4e4fdb5ce
fixes for bugs found by make_single_applets.sh
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-03 21:31:16 +02:00
Denys Vlasenko
2e989ef232
msh: delete this applet
...
It's deprecated since 2009 and interferes with make_single_applets.sh tests.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-03 16:56:37 +02:00
Denys Vlasenko
4ee824f6ba
randomconfig fixes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-03 01:22:13 +02:00
Denys Vlasenko
f547041940
ash,hush: fix SIGCHLD interrupting read builtin
...
function old new delta
readcmd 169 217 +48
shell_builtin_read 1087 1097 +10
localcmd 366 364 -2
builtin_read 197 193 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 58/-6) Total: 52 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-05-22 19:34:45 +02:00
Denys Vlasenko
10ad622dc2
Spelling fixes in comments, documentation, tests and examples
...
By klemens <ka7@github.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-17 16:13:32 +02:00
Denys Vlasenko
205d48e948
*: add comment about APPLET_ODDNAME format
...
It confused me more than once
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-29 14:57:33 +01:00
Denys Vlasenko
8944c67b1f
hush: reinstate [[ builtin
...
Mike deleted it:
commit 39456a18a1
Author: Mike Frysinger <vapier@gentoo.org>
Date: Sat Mar 28 12:21:57 2009 +0000
stop lying about [[ test support
probably because it was not properly ifdefed around, and was enabled
even when bash compat is off.
I just tested it - it works:
$ [ *.diff = z.diff ]; echo $?
0
$ [[ *.diff = z.diff ]]; echo $?
1
Of course, not all numerous bash tricks of [[ ]] are implemented...
function old new delta
bltins2 60 72 +12
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-11 14:22:00 +01:00
Kang-Che Sung
027d3ab57d
hush: split bash compatible extensions into separate defines. No code changes
...
Splitting these options makes it self-documenting about what
bash-compatible features we have.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-11 14:18:30 +01:00
Denys Vlasenko
80f806cac9
hush: shorten output of "help" builtin
...
text data bss dec hex filename
891272 485 6856 898613 db635 busybox_old
891232 485 6856 898573 db60d busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 16:51:10 +01:00
Denys Vlasenko
a1184af5f8
hush: reorder builtins (cd and pwd ought to be close, etc), no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 15:58:02 +01:00
Denys Vlasenko
265062d59d
shells: make hush test optional, rename ASH_BUILTIN_foo -> ASH_foo
...
This makes hash and ash more symmetrical wrt config menu and config
options.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 15:13:30 +01:00
Denys Vlasenko
f560422fa0
Big cleanup in config help and description
...
Redundant help texts (one which only repeats the description)
are deleted.
Descriptions and help texts are trimmed.
Some config options are moved, even across menus.
No config option _names_ are changed.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 14:58:54 +01:00
Denys Vlasenko
1cc6804f69
hush: make echo builtin optional
...
It's a bit overkill (who would want it off?) but ash already has it
configurable. Let's be symmetric.
Also tweak kbuild logic to use ASH_BUILTIN_ECHO to select echo.o,
not ASH.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09 17:10:04 +01:00
Denys Vlasenko
2b1559056c
hush: fix a bug in argv restoration after sourcing a file
...
if sourced file "shift"ed argvs so that $1 is NULL, restore wasn't done.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09 08:13:21 +01:00
Denys Vlasenko
4e4f88e569
hush: global_args_malloced is used only if set builtin is enabled
...
function old new delta
run_pipe 1623 1635 +12
builtin_source 210 222 +12
save_and_replace_G_args 70 60 -10
builtin_shift 132 94 -38
restore_G_args 98 - -98
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/2 up/down: 24/-146) Total: -122 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09 07:57:38 +01:00
Denys Vlasenko
cc2fd5a986
hush: fix 'defined but not used' warning
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09 06:19:55 +01:00
Denys Vlasenko
5362cc4b8c
hush: remove redundand test for ENABLE_HUSH_JOB
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09 05:57:13 +01:00
Denys Vlasenko
fd68f1e80d
hush: fix kill builtin without jobs support
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09 05:47:57 +01:00
Denys Vlasenko
442a414d66
typo fix
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09 05:11:09 +01:00
Denys Vlasenko
41ade05cac
hush: conditionalize print_escaped() on EXPORT || TRAP
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-08 18:56:24 +01:00
Denys Vlasenko
4471969db2
hush: make memleak builtin optional
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-08 18:44:41 +01:00
Denys Vlasenko
6ec76d8719
hush: make export builtin optional
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-08 18:40:41 +01:00
Denys Vlasenko
d5933b1125
hush: make umask builtin optional
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-08 18:31:39 +01:00
Denys Vlasenko
10d5ece64a
hush: make set/unset builtins optional
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-08 18:28:43 +01:00
Denys Vlasenko
7a85c60e7e
hush: make read and trap builtins optional
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-08 17:40:18 +01:00
Denys Vlasenko
1125d7d680
hush: kill builtin and kill %jobspec support
...
Also made it and printf, type and wait builtins optional.
function old new delta
builtin_kill - 323 +323
bltins1 336 348 +12
builtin_type 114 116 +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 337/0) Total: 337 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-08 17:19:38 +01:00
Denys Vlasenko
d5b5c2fa15
hush: support %%, %+ and % jobspec (meaning "current job")
...
function old new delta
parse_jobspec 83 133 +50
builtin_wait 278 283 +5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-08 15:46:04 +01:00
Denys Vlasenko
b05bcaf29c
hush: correct exitcode for unterminated ')' - exitcode2.tests testcase
...
function old new delta
parse_stream 2595 2609 +14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-03 11:47:50 +01:00
Denys Vlasenko
0b8835861b
Make it possible to select "sh" and "bash" aliases without selecting ash or hush
...
The same can be done for msh, but we are probably better off just deleting it
in a next versio or two.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-23 16:56:43 +01:00
Denys Vlasenko
6704746c69
shell: move "config" blocks above their use in coditional includes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-22 15:21:58 +01:00
Denys Vlasenko
b6afcc7819
shell: suppress "unused var/func" warnings on some configs
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-12 16:30:20 +01:00
Denys Vlasenko
4b89d512b1
ash,hush: make ^C in interactive mode visually much closer to bash behavior
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-25 03:41:03 +01:00
Denys Vlasenko
8660aeb312
ash,hush: ^C from command line should set $? to 128+SIGINT
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-24 17:44:02 +01:00
Denys Vlasenko
87e039d016
hush: make getch/peek functions directly called
...
Indirect calls are more difficult to predict.
Unfortunately, on x64 direct call is 5 bytes while indirect "call (reg+ofs)"
is 3 bytes:
function old new delta
i_getch - 82 +82
i_peek - 63 +63
parse_stream 2531 2579 +48
parse_dollar 771 797 +26
parse_redirect 296 321 +25
add_till_closing_bracket 408 420 +12
encode_string 256 265 +9
i_peek_and_eat_bkslash_nl 93 99 +6
add_till_backquote 110 114 +4
parse_and_run_stream 139 141 +2
expand_vars_to_list 1143 1144 +1
static_peek 6 - -6
setup_string_in_str 39 18 -21
setup_file_in_str 40 19 -21
static_get 27 - -27
file_peek 52 - -52
file_get 65 - -65
------------------------------------------------------------------------------
(add/remove: 2/4 grow/shrink: 9/2 up/down: 278/-192) Total: 86 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-08 22:35:05 +01:00
Denys Vlasenko
00a06b9715
hush: renumber PIPE_foo, make PIPE_SEQ = 0
...
PIPE_SEQ is used most often, having it zero makes code smaller:
function old new delta
done_word 719 707 -12
parse_stream 2546 2531 -15
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-08 20:35:53 +01:00
Denys Vlasenko
6c635d62d4
hush: small optimization in run_list
...
I thought gcc can detect this itself. It doesn't.
function old new delta
run_list 1030 1021 -9
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-08 20:26:11 +01:00
Denys Vlasenko
5cc9bf6a21
hush: deindent large block of code, no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-08 17:34:44 +01:00
Denys Vlasenko
1eada9ad8d
hush: simplify insert_bg_jobs
...
function old new delta
insert_bg_job 366 281 -85
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-08 17:28:45 +01:00
Denys Vlasenko
830ea35484
hush: make "wait %1" less likely to play with signal mask
...
Was playing with "sleep 3 | exit 3 & wait %1" and noticed that often
SIGCHLD arrives even before I get to signal masking. Can avoid it in this
case.
function old new delta
wait_for_child_or_signal 228 265 +37
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-08 04:59:11 +01:00
Denys Vlasenko
02affb4afd
hush: rework "wait %jobspec" to work in non-interactive shells too
...
Also add tests. wait5.tests so far fails (but works for ash and dash).
function old new delta
builtin_wait 305 283 -22
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-08 00:59:29 +01:00
Denys Vlasenko
26ad94bedc
hush: "wait $!; echo $?" should return 127 if $! already exited
...
It would be nice to provide bash-like "remember las exitcode"
thingy, but it's a bit complex. For now, match ash and dash.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-07 23:07:21 +01:00
Denys Vlasenko
62b717b75e
hush: implement "wait %jobspec"
...
function old new delta
parse_jobspec - 83 +83
job_exited_or_stopped - 79 +79
builtin_wait 236 302 +66
wait_for_child_or_signal 199 228 +29
checkjobs 142 158 +16
builtin_jobs 59 68 +9
process_wait_result 453 408 -45
builtin_fg_bg 272 203 -69
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 4/2 up/down: 282/-114) Total: 168 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-07 22:12:18 +01:00
Denys Vlasenko
4e1c8b4f6a
hush: factor out %jobspec parsing
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-07 20:06:40 +01:00
Denys Vlasenko
5d5a611df2
hush: comment fix
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-07 19:36:50 +01:00
Denys Vlasenko
4224647c8d
hush: do not allow sh -c '{ echo boo }'
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-07 16:22:35 +01:00
Denys Vlasenko
aeaee43d5a
hush: case logic for setting $? was still wrong
...
Resetting to 0 should happen in "esac". Matched branch must
still see previous $?.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-04 20:14:04 +01:00
Denys Vlasenko
30bfcf612b
hush: non-matching "case" statement sets $? to 0
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-04 18:52:48 +01:00
Denys Vlasenko
672a55e606
hush: allow { cmd } to not be terminated by semicolon in some cases
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-04 18:46:14 +01:00