Commit Graph

1037 Commits

Author SHA1 Message Date
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
Denys Vlasenko
9db74e49e5 hush: fix "(sleep 1; exit 3) & sleep 2; echo $?; wait $!; echo $?"
"wait $!" may be just a bit too late: backgrounded $! is gone.
Do not bomb out in this case.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-28 22:39:12 +02:00
Denys Vlasenko
7e6753609d hush: fix "wait PID"
It was not properly interruptible, and did not update job status
(the exited processes were still thought of as running).

function                                             old     new   delta
process_wait_result                                    -     453    +453
wait_for_child_or_signal                               -     199    +199
run_list                                             996    1002      +6
checkjobs_and_fg_shell                                41      43      +2
builtin_wait                                         328     215    -113
checkjobs                                            516     142    -374
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/2 up/down: 660/-487)          Total: 173 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-28 21:59:09 +02:00
Denys Vlasenko
2eb0a7e1b9 ash: [SHELL] Expand ENV before using it
Upstream commit:

    Date: Sun, 13 Jul 2008 21:51:52 +0800
    [SHELL] Expand ENV before using it

    Per POSIX ENV needs to undergo parameter expansion.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-27 11:28:59 +02:00
Denys Vlasenko
b7adf7ac32 ash,hush: set exit code 127 in "sh /does/not/exist" case
Upstream commit 1 for ash:

    [ERROR] Allow the originator of EXERROR to set the exit status

    Some errors have exit status values specified by POSIX and it is
    therefore desirable to be able to set the exit status at the EXERROR
    source rather than in main.c.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Upstream commit 2 for ash:

    [INPUT] Use exit status 127 when the script to run does not exist

    This commit makes dash exit with return code 127 instead of 2 if
    started as non-interactive shell with a non-existent command_file
    specified as argument (or a directory), as documented in
     http://www.opengroup.org/onlinepubs/009695399/utilities/sh.html#tag_04_128_14

    The wrong exit code was reported by Clint Adams and Jari Aalto through
     http://bugs.debian.org/548743
     http://bugs.debian.org/548687

    Signed-off-by: Gerrit Pape <pape@smarden.org>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

NB: in fact, http://bugs.debian.org/548687 was not fixed by this:
"sh /dir/" thinks that EISDIR error on read is EOF, and exits 0.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-25 17:00:13 +02:00
Denys Vlasenko
7f0ebbc69e hush: add commented-out debug printouts in "memleak" built-in
Allocation addresses of malloc() are jittery,
thought I had a mem leak in hush, but it was malloc variability.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 17:42:53 +02:00
Denys Vlasenko
a769390da6 hush: fix a memory corruption when exported variable is modified
The construct such as this:

t=1
export t
t=new_value1

had a small probability of momentarily using free()d value.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 15:01:06 +02:00
Denys Vlasenko
04465dad66 hush: fix exitcode on exec failure with EACCES - should be 126
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 01:01:15 +02:00
Denys Vlasenko
80729a4472 whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 22:33:15 +02:00
Denys Vlasenko
61508d9624 hush: fix var3.tests
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 21:12:02 +02:00
Denys Vlasenko
ebedb9478d sh: do not print empty line at the end of "help" output
It's pointless.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02 18:45:09 +02:00
Denys Vlasenko
04b46bced9 hush: 'return' should have effect earlier
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 22:28:03 +02:00
Denys Vlasenko
ed6ff5edfc hush: enable "msh is deprecated" message in msh stub
After giving a few more years for everyone to notice and migrate,
can nuke all remains of msh.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 12:28:37 +02:00
Denys Vlasenko
08755f9bcb hush: fix typo in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 02:02:25 +02:00
Denys Vlasenko
4074d49557 hush: fix interactive input handling of backslash+newline
function                                             old     new   delta
fgetc_interactive                                      -     258    +258
i_peek_and_eat_bkslash_nl                             43      93     +50
static_peek2                                           7       -      -7
setup_string_in_str                                   46      39      -7
setup_file_in_str                                     47      40      -7
file_peek                                             72      52     -20
expand_vars_to_list                                 1167    1143     -24
file_peek2                                            74       -     -74
file_get                                             326      65    -261
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 1/5 up/down: 308/-400)          Total: -92 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 01:49:53 +02:00
Denys Vlasenko
0448c55cc8 hush: G.user_input_buf[] is needed only if line editing is enabled
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 20:25:44 +02:00
Denys Vlasenko
46e6498b2a hush: speed optimizations
Make o_addchr() faster: do not call o_grow_by() each time.
Create i_getch_and_eat_bkslash_nl(), use it instead of peek+getch pair.

function                                             old     new   delta
o_addchr                                              42      54     +12
parse_dollar                                         761     771     +10
o_grow_by                                             48      37     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 24/-11)             Total: 11 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 19:50:55 +02:00
Denys Vlasenko
657086a3dc hush: fix handling of by backslash-newline in $((arith)) and $(cmd)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 18:07:42 +02:00
Denys Vlasenko
d17a91db6e hush: rework input char buffering to allow more than one-deep peek
...this time with actual hush.c changes too :)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 18:02:37 +02:00
Denys Vlasenko
78c9c736ab hush: fix 'eval ""' handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 01:44:17 +02:00
Denys Vlasenko
992e0ff7e9 hush: fix ". EMPTY_LINE" not setting $? to 0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 01:27:09 +02:00
Denys Vlasenko
d6a37d86ba hush: document better where bad redirect syntax is detected
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-20 16:22:24 +02:00
Denys Vlasenko
aa3576a29b hush: fix "redirects can close script fd" bug
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-22 19:54:12 +02:00
Denys Vlasenko
7b25b1c5b2 hush: do not leak script fds into NOEXEC children
We set all opened script fds to CLOEXEC, thus making then go away
after fork+exec.
Unfortunately, CLOFORK does not exist. NOEXEC children will still see those fds open.

For one, "ls" applet is NOEXEC. Therefore running "ls -l /proc/self/fd"
in a script from standalone shell shows this:

lrwx------    1 root     root            64 Aug 20 15:17 0 -> /dev/pts/3
lrwx------    1 root     root            64 Aug 20 15:17 1 -> /dev/pts/3
lrwx------    1 root     root            64 Aug 20 15:17 2 -> /dev/pts/3
lr-x------    1 root     root            64 Aug 20 15:17 3 -> /path/to/top/level/script
lr-x------    1 root     root            64 Aug 20 15:17 4 -> /path/to/sourced/SCRIPT1
...

with as many open fds as there are ". SCRIPTn" nest levels.
Fix it by closing these fds after fork (only for NOEXEC children).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-20 15:58:34 +02:00
Denys Vlasenko
869994cf4f hush: bit better comments in redirect code. No logic changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-20 15:16:00 +02:00
Denys Vlasenko
e9abe75fda hush: cmd and arithmetic also need the fix for FILE rewind
Discovered by running testsuite with a newest glibc

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-19 20:15:26 +02:00
Denys Vlasenko
215b0ca6e4 hush: fix a bug in FEATURE_SH_STANDALONE=y config. Closes 9186
Run this in a "sh SCRIPT":

sha256sum /dev/null
echo END

sha256sum is a NOEXEC applet. It runs in a forked child. Then child exit()s.
By this time, entire script is read, and buffered in a FILE object
from fopen("SCRIPT"). But fgetc() did not consume entire input.
exit() lseeks back by -9 bytes, from <eof> to 'e' in 'echo'.
(this may be libc-specific).
This change of fd position *is shared with the parent*!

Now parent can read more, and it thinks there is another "echo END".
End result: two "echo END"s are run.

Fix this by _exit()ing instead.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-19 18:43:06 +02:00
Denys Vlasenko
49117b4800 hush: fix a possible bug
Not sure this was actually a triggerable bug, but the code looked flaky.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-21 14:42:13 +02:00
Denys Vlasenko
85378cded7 hush: code shrink
function                                             old     new   delta
builtin_wait                                         347     328     -19

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-11 21:47:11 +02:00
Denys Vlasenko
550bf5b4a4 remove global "jmp_buf die_jmp" from !FEATURE_PREFER_APPLETS builds
function                                             old     new   delta
xfunc_has_died                                         -      21     +21
sleep_much                                             -      12     +12
sleep10                                                -       9      +9
die_func                                               -       4      +4
fflush_stdout_and_exit                                35      36      +1
builtin_type                                         121     119      -2
die_sleep                                              4       -      -4
xfunc_die                                             60      24     -36
hush_main                                           1128    1011    -117
die_jmp                                              156       -    -156
------------------------------------------------------------------------------
(add/remove: 4/2 grow/shrink: 1/3 up/down: 47/-315)          Total: -268 bytes
   text	   data	    bss	    dec	    hex	filename
 939992	    992	  17652	 958636	  ea0ac	busybox_old
 939880	    992	  17496	 958368	  e9fa0	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-09 16:42:57 +02:00
Denys Vlasenko
d60752f8c9 build system: -fno-builtin-printf
Benefits are: drops reference to out-of-line putchar(), fixes a few cases
of failed string merge.

function                                             old     new   delta
i2cdump_main                                        1488    1502     +14
sha256_process_block64                               423     433     +10
sendmail_main                                       1183    1185      +2
list_table                                          1114    1116      +2
i2cdetect_main                                      1235    1237      +2
fdisk_main                                          2852    2854      +2
builtin_type                                         119     121      +2
unicode_conv_to_printable2                           325     324      -1
scan_recursive                                       380     378      -2
mkfs_minix_main                                     2687    2684      -3
buffer_fill_and_print                                178     169      -9
putchar                                              152       -    -152
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 7/4 up/down: 34/-167)          Total: -133 bytes
   text    data     bss     dec     hex filename
 937788     932   17676  956396   e97ec busybox_old
 937564     932   17676  956172   e970c busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-07 22:42:45 +02:00
Denys Vlasenko
5711a2a4ad libbb: more compact API for bb_parse_mode()
function                                             old     new   delta
make_device                                         2182    2188      +6
parse_command                                       1440    1443      +3
parse_params                                        1497    1499      +2
install_main                                         773     769      -4
mkdir_main                                           168     160      -8
getoptscmd                                           641     632      -9
builtin_umask                                        158     147     -11
bb_parse_mode                                        431     410     -21
umaskcmd                                             286     258     -28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/6 up/down: 11/-81)            Total: -70 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-07 17:55:33 +02:00
Denys Vlasenko
6283f98283 hush: fix umask: umask(022) was setting umask(755)
Based on the patch by Rich Felker <dalias@libc.org>

function                                             old     new   delta
builtin_umask                                        121     161     +40
umaskcmd                                             318     279     -39

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-07 16:56:20 +02:00
Denys Vlasenko
b5be13ccd9 hush: fix a nommu bug where a part of function body is lost if run in a pipe
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-09-04 06:22:10 +02:00
Maninder Singh
97f2f7ca7f Removes stray empty line from code
This patch removes stray empty line from busybox code
reported by script find_stray_empty_lines

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-13 03:25:46 +02:00
Maninder Singh
97c6491b4e typo fixes
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-25 13:46:36 +02:00
Denys Vlasenko
8dff01d06a libbb: introduce and use is_prefixed_with()
function                                             old     new   delta
is_prefixed_with                                       -      18     +18
complete_username                                     78      77      -1
man_main                                             737     735      -2
fsck_device                                          429     427      -2
unpack_ar_archive                                     80      76      -4
strip_unsafe_prefix                                  105     101      -4
singlemount                                         1054    1050      -4
rtc_adjtime_is_utc                                    90      86      -4
resolve_mount_spec                                    88      84      -4
parse_one_line                                      1029    1025      -4
parse_conf                                          1460    1456      -4
may_wakeup                                            83      79      -4
loadkmap_main                                        219     215      -4
get_irqs_from_stat                                   103      99      -4
get_header_cpio                                      913     909      -4
findfs_main                                           79      75      -4
fbsplash_main                                       1230    1226      -4
load_crontab                                         776     771      -5
expand_vars_to_list                                 1151    1146      -5
date_main                                            881     876      -5
skip_dev_pfx                                          30      24      -6
make_device                                         2199    2193      -6
complete_cmd_dir_file                                773     767      -6
run_applet_and_exit                                  715     708      -7
uudecode_main                                        321     313      -8
pwdx_main                                            197     189      -8
execute                                              568     560      -8
i2cdetect_main                                      1186    1176     -10
procps_scan                                         1242    1230     -12
procps_read_smaps                                   1017    1005     -12
process_module                                       746     734     -12
patch_main                                          1903    1891     -12
nfsmount                                            3572    3560     -12
stack_machine                                        126     112     -14
process_timer_stats                                  449     435     -14
match_fstype                                         111      97     -14
do_ipaddr                                           1344    1330     -14
open_list_and_close                                  359     343     -16
get_header_tar                                      1795    1779     -16
prepend_new_eth_table                                340     323     -17
fsck_main                                           1811    1794     -17
find_iface_state                                      56      38     -18
dnsd_main                                           1321    1303     -18
base_device                                          179     158     -21
find_keyword                                         104      82     -22
handle_incoming_and_exit                            2785    2762     -23
parse_and_put_prompt                                 774     746     -28
modinfo                                              347     317     -30
find_action                                          204     171     -33
update_passwd                                       1470    1436     -34
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/49 up/down: 18/-540)         Total: -522 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-12 17:48:34 +01:00
Denys Vlasenko
841f8331d7 ash,hush: run reinit_unicode() only if makes sense
With static Unicode support, no need to check $LANG et al.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-08-13 10:09:49 +02:00
Denys Vlasenko
c538d5bcc3 hush: make ${#var} unicode-aware
This mimics bash

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-08-13 09:57:44 +02:00
Denys Vlasenko
3fa97af7cc ash,hush: set $HOSTNAME is bash compat. Closes 7028
function                                             old     new   delta
hush_main                                           1056    1128     +72
ash_main                                            1442    1487     +45

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-15 11:43:29 +02:00
Denys Vlasenko
2bba591991 hush: make "true" built-in
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-03-14 12:43:57 +01:00
Denys Vlasenko
8bd810bd27 hush: typo fixes in comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-28 01:50:01 +01:00
Denys Vlasenko
e95738f635 typo fix in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-08 03:13:08 +02:00
Denys Vlasenko
2301d127a2 unicode: check $LC_CTYPE too to detect Unicode mode
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-05 22:00:57 +02:00
Denys Vlasenko
3e7ecb179b unicode: check $LC_ALL to detect Unicode mode, not only $LANG
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-02 17:30:23 +02:00
Denys Vlasenko
ff463a885d hush: fix build failure if FEATURE_EDITING=y && !HUSH_INTERACTIVE
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-05-12 02:45:23 +02:00
Flemming Madsen
d96ffda62e ash,hush: history builtin
function                                             old     new   delta
show_history                                           -      39     +39
builtin_history                                        -      16     +16
historycmd                                             -      13     +13
bltins1                                              312     324     +12
builtintab                                           336     344      +8
popstring                                            134     140      +6
hush_main                                           1048    1046      -2
ash_main                                            1398    1396      -2
size_from_HISTFILESIZE                                44      40      -4
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 3/3 up/down: 94/-8)              Total: 86 bytes

Signed-off-by: Flemming Madsen <busybox@themadsens.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-04-07 18:47:24 +02:00
Denys Vlasenko
3beab83e4f hush: fix for "while false && true; do echo BUG; break; done". closes 6170
function                                             old     new   delta
run_list                                             959     941     -18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-04-07 18:16:58 +02:00
Denys Vlasenko
88b532d59a hush: source builtin should override $N only if it has args
function                                             old     new   delta
builtin_source                                       174     184     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-17 14:11:04 +01:00
Denys Vlasenko
6830ade6aa whitespace fixes. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 13:58:01 +01:00
Denys Vlasenko
60cb48ca50 whitespace cleanup. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 15:57:44 +01:00
Denys Vlasenko
9d75370238 hush: remove sighandler_t definition hack, platform.h has it too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-26 10:59:01 +02:00
Denys Vlasenko
8cab66730a fix build breakage found by randconfig
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-20 14:48:00 +02:00
Denys Vlasenko
0d6bbb0497 hush: remove unused member struct command::is_stopped
function                                             old     new   delta
builtin_umask                                        133     132      -1
checkjobs                                            551     544      -7
builtin_fg_bg                                        291     267     -24

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-27 14:32:48 +02:00
Denys Vlasenko
e45af7ad17 lineedit: remove SAVE_HISTORY bit, ->hist_file can be used as indicator
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-04 16:15:24 +02:00
Denys Vlasenko
bede215cf1 lineedit: add support for history saving on exit
Based on the patch by Dennis Groenen <tj.groenen@gmail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-04 16:12:33 +02:00
Denys Vlasenko
4840ae8a06 lineedit: fix atomic replace of history file; hush: fix $HISTFILE handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-04 15:28:03 +02:00
Denys Vlasenko
b347df9131 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-09 22:49:15 +02:00
Denys Vlasenko
6e42b89b8d hush: fix remaining known two bugs with IFS expansion. Closes 4027.
function                                             old     new   delta
expand_vars_to_list                                 1054    1140     +86
parse_stream                                        2425    2479     +54
expand_on_ifs                                        258     310     +52
builtin_umask                                        133     132      -1
done_word                                            820     779     -41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 192/-42)           Total: 150 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-01 18:16:43 +02:00
Denys Vlasenko
4fb53fb08c hush: partially fix wrong expansion on $IFS (bug 4027).
In the added testcase, before patch we failed 8 out of 9 tests,
now we fail only 2 (4th and 5th).

function                                             old     new   delta
expand_on_ifs                                        225     258     +33
expand_vars_to_list                                 1038    1054     +16
o_save_ptr_helper                                    115     119      +4
builtin_umask                                        132     133      +1
o_addQstr                                            165     161      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 54/-4)              Total: 50 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-01 14:06:20 +02:00
Denys Vlasenko
56a3b82e96 hush: better comment. No code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-01 12:47:07 +02:00
Denys Vlasenko
00ae989ee5 hush: fix a corner case of empty "do \n done" structure
The structure is:

    while cmd; do
    done

bash doesn't accept it at all. We were accepting it but execution
was buggy.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-31 17:35:45 +02:00
Denys Vlasenko
29f9b7268a hush: fix misparsing of "... do eval a= ...". Closes 3721
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-14 11:27:36 +02:00
Denys Vlasenko
60a9414cad fix "variable 'foo' set but not used" warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-13 20:57:01 +02:00
Denys Vlasenko
0806e401d6 hush: install signal handlers with filled sigmask
function                                             old     new   delta
install_sighandler                                     -      39     +39
hush_main                                           1001    1031     +30
builtin_trap                                         386     392      +6
install_sighandlers                                  121     123      +2
switch_off_special_sigs                               87      86      -1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 77/-1)              Total: 76 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-12 23:06:20 +02:00
Denys Vlasenko
75e77deab1 hush: fixes and small shrink for HUSH_JOB!=y
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-12 13:12:47 +02:00
Denys Vlasenko
ebc1ee2e2a hush: remove one sigprocmask from exit path
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-12 10:59:18 +02:00
Denys Vlasenko
0c40a731e3 hush: add forgotten {} in multi-statement if.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-12 09:50:12 +02:00
Denys Vlasenko
f58f705c58 hush: fix login shell's signal handling; add -l option so that it's easier to test
function                                             old     new   delta
hush_main                                            958    1001     +43
install_special_sighandlers                           47      52      +5
packed_usage                                       28752   28741     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 48/-11)             Total: 37 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-12 02:10:33 +02:00
Denys Vlasenko
9d6cbafe72 hush: replace signal handling machinery
With new version of signal handling, read builtin should be less buggy
wrt signals.

function                                             old     new   delta
install_sighandlers                                    -     121    +121
switch_off_special_sigs                                -      84     +84
pick_sighandler                                        -      58     +58
install_special_sighandlers                            -      47     +47
builtin_wait                                         284     319     +35
record_pending_signo                                   -      21     +21
execvp_or_die                                         43      48      +5
file_get                                             290     288      -2
run_list                                            1004     998      -6
static.zero_timespec                                   8       -      -8
sigprocmask_set                                       14       -     -14
sigwaitinfo                                           23       -     -23
record_signal                                         23       -     -23
__GI_sigwaitinfo                                      23       -     -23
sigtimedwait                                          25       -     -25
builtin_trap                                         417     392     -25
__GI_sigtimedwait                                     25       -     -25
hush_main                                           1003     965     -38
check_and_run_traps                                  263     217     -46
__rt_sigtimedwait                                     52       -     -52
reset_traps_to_defaults                              213     126     -87
init_sigmasks                                        198       -    -198
builtin_read                                         536     197    -339
------------------------------------------------------------------------------
(add/remove: 5/10 grow/shrink: 2/7 up/down: 371/-934)        Total: -563 bytes
   text	   data	    bss	    dec	    hex	filename
 903075	    936	  17736	 921747	  e1093	busybox_old
 902547	    936	  17736	 921219	  e0e83	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-11 23:56:11 +02:00
Denys Vlasenko
10c0131a8a hush: use SA_RESTARTed signal handlers across read.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-11 11:49:21 +02:00
Denys Vlasenko
54e9e1217c hush: code shrink
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-09 00:52:15 +02:00
Denys Vlasenko
80542bad2f hush: make read builtin interruptible.
function                                             old     new   delta
builtin_read                                         185     471    +286
check_and_run_traps                                  200     262     +62
nonblock_immune_read                                  73     119     +46
sigismember                                            -      44     +44
record_signal                                          -      21     +21
sigisemptyset                                          -      16     +16
...
------------------------------------------------------------------------------
(add/remove: 5/0 grow/shrink: 7/5 up/down: 483/-46)           Total: 437 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-08 21:23:43 +02:00
Denys Vlasenko
b8709032a3 hush: fix incorrect PS2 dispaly and trap handling while reading command
The fix affects only !ENABLE_FEATURE_EDITING configuration

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-08 21:20:01 +02:00
Denys Vlasenko
2c4de5b045 ash,hush: optional support for $HISTFILESIZE.
Based on patch from Alexey Fomenko (ext-alexey.fomenko AT nokia.com)

function                                             old     new   delta
size_from_HISTFILESIZE                                 -      44     +44
hush_main                                            998    1025     +27
ash_main                                            1348    1374     +26
read_line_input                                     3361    3372     +11
new_line_input_t                                      17      24      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-31 13:16:52 +02:00
Denys Vlasenko
a439fa93f6 hush: remove outdated comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-30 19:11:46 +02:00
Denys Vlasenko
cecbc98611 hush: fix source1.tests
function                                             old     new   delta
parse_and_run_stream                                  95     139     +44
static_get                                            22      25      +3
file_get                                             260     263      +3
builtin_umask                                        133     132      -1
parse_stream                                        2442    2425     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 50/-18)             Total: 32 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-30 18:54:52 +02:00
Denys Vlasenko
3eab24e64a hush: make parse errors in sourced file non-fatal in interactive script
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-24 05:25:59 +01:00
Denys Vlasenko
68d5cb5dac hush: fix a case where return in sourced file has no effect
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-24 02:50:03 +01:00
Denys Vlasenko
20704f0662 ash,hush: recheck LANG before every line input
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-23 17:59:27 +01:00
Denys Vlasenko
6b6af53426 ash/hush: shrink help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-08 10:24:17 +01:00
Denys Vlasenko
b0b834342f ash/hush: provide help text
$ ./busybox ash --help
BusyBox v1.19.0.git (2011-03-07 11:25:29 CET) multi-call binary.

Usage: ash [-/+OPTCHARS] [-/+o OPTNAME]... [-c 'SCRIPT' [ARG0 [ARGS]] / SCRIPT_FILE [ARGS]]

Unix shell interpreter

$ ./busybox hush --help
BusyBox v1.19.0.git (2011-03-07 11:25:29 CET) multi-call binary.

Usage: hush [-nx] [-c 'SCRIPT' [ARG0 [ARGS]] / SCRIPT_FILE [ARGS]]

Unix shell interpreter

function                                             old     new   delta
packed_usage                                       28163   28212     +49
setcmd                                                85      78      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 49/-7)              Total: 42 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-07 12:34:59 +01:00
Denys Vlasenko
7c6f2468cc hush: do not print killer signal's name for SIGPIPE
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-14 17:17:10 +01:00
Denys Vlasenko
66c5b12dbf ash: fix TMOUT not restoring tty attributes
function                                             old     new   delta
pgetc                                                420     500     +80
readtoken1                                          3202    3239     +37
read_line_input                                     3316    3337     +21
udhcpc_main                                         2610    2630     +20
file_get                                             266     272      +6
expandarg                                            958     963      +5
localcmd                                             257     259      +2
addLines                                              85      87      +2
read_line                                             94      95      +1
ed_main                                             2540    2541      +1
timed_out                                              1       -      -1
lineedit_read_key                                    256     255      -1
alrm_sighandler                                       44       -     -44
cmdloop                                              539     434    -105
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 10/2 up/down: 175/-151)          Total: 24 bytes
   text    data     bss     dec     hex filename
 887379     936   17200  905515   dd12b busybox_old
 887411     936   17192  905539   dd143 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-08 05:07:02 +01:00
Denys Vlasenko
8ee2adab21 echo: do not retry on write errors
function                                             old     new   delta
echo_main                                            297     336     +39
stpcpy                                                 -      22     +22
run_pipe                                            1561    1566      +5
pseudo_exec_argv                                     187     192      +5
hush_exit                                             75      80      +5
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 4/0 up/down: 98/0)               Total: 76 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-07 02:03:51 +01:00
Denys Vlasenko
b72baeb003 hush: use FEATURE_SH_NOFORK to enable NOFORK trick
Also expands docs

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-02 18:38:57 +01:00
Denys Vlasenko
a146319173 hush: improve prompt in nested {}s, remove unused in_str->promptme member
function                                             old     new   delta
setup_string_in_str                                   29      38      +9
parse_and_run_stream                                  79      88      +9
setup_file_in_str                                     32      39      +7
parse_stream                                        2430    2422      -8
file_get                                             262     235     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 25/-35)            Total: -10 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-18 17:55:04 +01:00
Denys Vlasenko
98c46d10ee hush: fix "cmd & <newline>" problem
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-18 17:30:07 +01:00
Denys Vlasenko
b9f2d9f7d9 mass removal of underscores from _BB_DIR_foo and _BB_SUID_foo
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-18 13:58:01 +01:00
Denys Vlasenko
642e71a789 hush: fix wrong prompt problem on empty interactive commants
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2011-01-07 15:16:05 +01:00
Denys Vlasenko
75eb9d20e9 hush: fix FEATURE_CLEAN_UP code (was freeing unallocated memory)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-12-21 21:18:12 +01:00
Denys Vlasenko
0d6a4ecb30 hush: fix build breakage (variable declared in for())
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-12-18 01:34:49 +01:00
Denys Vlasenko
8da415ef25 add if guards around include <malloc.h>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-12-05 01:30:14 +01:00
Denys Vlasenko
57542ebe4f hush: move G_x_mode define to the more appropriate place
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-28 03:59:30 +01:00
Dan Fandrich
85c62470b7 Support set -o xtrace/noexec alternates for set -x/-n
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-28 03:56:39 +01:00
Dan Fandrich
89ca2f99a2 hush: display useful help text
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-28 01:54:39 +01:00
Denys Vlasenko
26777aa1c6 fixes for bugs discovered by randomconfig builds and tests
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-22 23:49:10 +01:00
Denys Vlasenko
7b4c0fd5f4 hush: fix improper handling of newline and hash chars in few corner cases
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-11-22 17:58:14 +01:00
Denys Vlasenko
6696eac274 hush: add support for "set -o pipefail"
function                                             old     new   delta
checkjobs                                            467     517     +50
builtin_set                                          259     286     +27
o_opt_strings                                          -      10     +10
hush_main                                           1011    1013      +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 89/0)               Total: 89 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-14 02:01:50 +01:00
Denys Vlasenko
c08c3f5d26 hush: preparatory patch for set -o pipefail support
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-14 01:59:55 +01:00
Denys Vlasenko
e4dcba1c10 *: whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-28 18:57:19 +02:00
Denys Vlasenko
e2069fb325 hush: remove "doesn't support brace expansion" from config help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-04 00:01:47 +02:00
Denys Vlasenko
bbecd74d5a hush: remove brace expansion from TODO list in comments. No code changes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-03 17:22:52 +02:00
Denys Vlasenko
957f79f471 hush: small code shrink
function                                             old     new   delta
expand_on_ifs                                        231     222      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-03 17:15:50 +02:00
Denys Vlasenko
9e800223f1 hush: implement brace expansion
When enabled:

function                                             old     new   delta
glob_brace                                             -     402    +402
next_brace_sub                                         -      70     +70
expand_on_ifs                                        185     231     +46
bbconfig_config_bz2                                 4923    4929      +6
o_save_ptr                                           282     140    -142
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/1 up/down: 524/-142)          Total: 382 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-03 14:28:04 +02:00
Denys Vlasenko
238081f750 hush: preparatory patch, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-03 14:26:26 +02:00
Denys Vlasenko
0e13b4019c hush: use smaller EXP_FLAG_foo constants
function                                             old     new   delta
expand_string_to_string                              126     124      -2
parse_stream                                        2376    2370      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-8)               Total: -8 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-21 12:35:39 +02:00
Denys Vlasenko
52e460b744 hush: move shell_ver from globals to main's stack.
function                                             old     new   delta
hush_main                                            995    1011     +16
pseudo_exec_argv                                     253     251      -2
execvp_or_die                                         50      48      -2
maybe_set_to_sigexit                                  50      47      -3
hush_exit                                             78      75      -3
builtin_wait                                         274     271      -3
check_and_run_traps                                  205     200      -5
init_sigmasks                                        214     190     -24
builtin_trap                                         465     441     -24
reset_traps_to_defaults                              238     211     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/9 up/down: 16/-93)            Total: -77 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-16 16:12:00 +02:00
Denys Vlasenko
bed7c81ea2 shell/math: deconvolute and explain ?: handling. Give better error message
function                                             old     new   delta
arith_apply                                         1271    1283     +12

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-16 11:50:46 +02:00
Denys Vlasenko
063847d6bd shell/math: return string error indicator, not integer
function                                             old     new   delta
expand_and_evaluate_arith                             87     106     +19
expand_one_var                                      1563    1570      +7
arith                                                 12      18      +6
evaluate_string                                      678     680      +2
arith_apply                                         1269    1271      +2
builtin_umask                                        133     132      -1
ash_arith                                            118      75     -43
expand_vars_to_list                                 1094    1038     -56
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/3 up/down: 36/-100)           Total: -64 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-15 13:33:02 +02:00
Denys Vlasenko
06d44d7dfb shell/math.c: rename arith_eval_hooks to arith_state, put error code into it
function                                             old     new   delta
expand_and_evaluate_arith                             79      89     +10
arith                                                675     674      -1
arith_lookup_val                                     151     142      -9
ash_arith                                            135     122     -13
arith_apply                                         1304    1269     -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 10/-58)            Total: -48 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-13 12:49:03 +02:00
Denys Vlasenko
b771c654ca shell: shrink arith code; and prepare for returning text error codes
function                                             old     new   delta
arith                                                701     680     -21

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-13 00:34:26 +02:00
Denys Vlasenko
99862cbfad hush: optional support for history saving
function                                             old     new   delta
hush_main                                            945     995     +50

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 17:34:13 +02:00
Denys Vlasenko
de8c3f667a hush: move the EXIT trap comment. no code changes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 16:13:44 +02:00
Denys Vlasenko
a110c90de2 hush: fix EXIT trap display inside exit trap handler
function                                             old     new   delta
hush_exit                                             84      78      -6

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 15:38:04 +02:00
Denys Vlasenko
acd5bc8f64 hush: fix handling of \" in quoted/unquoted cmd
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 15:05:39 +02:00
Denys Vlasenko
5277a9db70 hush: remove forgotten commented-out block. no code changes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 15:34:53 +02:00
Denys Vlasenko
4f870496e7 hush: do fewer strdups in % and hash expansions
function                                             old     new   delta
builtin_umask                                        133     132      -1
expand_one_var                                      1552    1543      -9

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 11:06:01 +02:00
Denys Vlasenko
d98e5c65c3 hush: better function and parameter names
Also, trim code which isn't needed for non-bash compat.
No logic changes.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:44:23 +02:00
Denys Vlasenko
ebee410fe2 hush: fix var_bash5.tests failure
function                                             old     new   delta
expand_one_var                                      1513    1552     +39
expand_pseudo_dquoted                                118     135     +17
expand_string_to_string                              110     126     +16
setup_heredoc                                        298     308     +10
expand_and_evaluate_arith                             69      79     +10
parse_stream_dquoted                                 233     241      +8
setup_redirects                                      220     225      +5
run_list                                             956     961      +5
expand_assignments                                    76      81      +5
run_pipe                                            1587    1590      +3
parse_stream                                        2371    2374      +3
builtin_umask                                        132     133      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 12/0 up/down: 122/0)            Total: 122 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:17:53 +02:00
Denys Vlasenko
14e289b324 hush: fix var_bash3.tests failure
function                                             old     new   delta
expand_one_var                                      1513    1538     +25
parse_stream_dquoted                                 233     241      +8
expand_pseudo_dquoted                                118     126      +8
setup_heredoc                                        298     303      +5
expand_and_evaluate_arith                             69      74      +5
parse_stream                                        2371    2374      +3
builtin_umask                                        132     133      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/0 up/down: 55/0)               Total: 55 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:15:18 +02:00
Denys Vlasenko
a769e0225d hush: remove useless ESC_GLOB_CHARS clears/resotres
function                                             old     new   delta
o_addQstr                                             43     165    +122
expand_on_ifs                                        210     189     -21
expand_vars_to_list                                 1122    1094     -28
o_addqblock                                          139       -    -139
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/2 up/down: 122/-188)          Total: -66 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:12:34 +02:00
Denys Vlasenko
bfc02a76c5 hush: fix a bug where expand_one_var wasn't restoring 1st char of the encoded $var
function                                             old     new   delta
expand_one_var                                      1515    1513      -2
expand_vars_to_list                                 1133    1122     -11

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 14:38:46 +02:00
Denys Vlasenko
101a4e3e21 hush: make parse_dollar flag quited status regardless of glob escaping status
function                                             old     new   delta
parse_stream_dquoted                                 228     233      +5
parse_stream                                        2369    2371      +2
parse_dollar                                         730     717     -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 7/-13)              Total: -6 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 14:04:57 +02:00
Denys Vlasenko
5b6210cf49 hush: simplification in parse_stream, parse_stream_dquoted
function                                             old     new   delta
parse_stream                                        2354    2369     +15
parse_stream_dquoted                                 250     228     -22

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 13:32:21 +02:00
Denys Vlasenko
850b15bfaf hush: simplify parse_stream_dquoted
function                                             old     new   delta
parse_stream_dquoted                                 303     250     -53

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 12:58:19 +02:00
Denys Vlasenko
77a7b5519c hush: straighten out the logic in parse_stream
function                                             old     new   delta
parse_stream                                        2399    2354     -45

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 12:40:03 +02:00
Denys Vlasenko
95d48f2598 hush: eliminate redundant parameter of expand_vars_to_list()
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-08 13:58:55 +02:00
Denys Vlasenko
5b686cb8e6 hush: replace flag bytes in struct o_string with bit flags
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-08 13:44:34 +02:00
Denys Vlasenko
9b78255dca hush: remove unused enum typedef
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-08 13:33:26 +02:00
Denys Vlasenko
1fd3d94a6c hush: fix set -- q w e; (IFS='' echo "$*"; IFS=''; echo "$*"); echo "$*"
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-08 13:31:53 +02:00
Denys Vlasenko
8b2f13d84d shell: unify endofname() in hush and ash
function                                             old     new   delta
builtin_umask                                        132     133      +1
changepath                                           195     194      -1
expand_and_evaluate_arith                             77      69      -8
ash_arith                                            143     135      -8
expand_one_var                                      1551    1515     -36
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 1/-53)             Total: -52 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-07 12:19:33 +02:00
Denys Vlasenko
27c56f1267 hush: a few relatively trivial simplifications
function                                             old     new   delta
helper_export_local                                  130     135      +5
set_vars_and_save_old                                 89      85      -4
expand_variables                                     147     141      -6
get_ptr_to_local_var                                  77      70      -7
get_local_var_value                                  171     164      -7
delete_finished_bg_job                                31      16     -15
hush_exit                                            101      84     -17
free_pipe_list                                        31      12     -19
check_and_run_traps                                  232     205     -27
free_pipe                                            205     130     -75
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/9 up/down: 5/-177)           Total: -172 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-07 09:56:34 +02:00
Denys Vlasenko
da463fb007 hush: style cleanups. no code changes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-07 09:53:50 +02:00
Denys Vlasenko
605067b426 hush: revert a recent buggy change which resulted in two HUSH_VERSIONs
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 12:10:51 +02:00
Denys Vlasenko
83b900fb82 fix typo in comment
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 11:47:55 +02:00
Denys Vlasenko
c3adfacd22 hush: fix another corner case with backslashes in heredocs
function                                             old     new   delta
parse_stream                                        2395    2432     +37

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 11:46:03 +02:00
Denys Vlasenko
77b32ccbf2 hush: fix backslash and terminator handling in <<[-]["]heredoc["]
function                                             old     new   delta
parse_stream                                        2339    2395     +56
expand_pseudo_dquoted                                104     118     +14
parse_stream_dquoted                                 296     300      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 74/0)               Total: 74 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 11:27:32 +02:00
Denys Vlasenko
c49d2d9793 hush: fix globbing+backslashes in unquoted $var expansion
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 10:26:37 +02:00
Denys Vlasenko
d383b49aef hush: remove disabled CMD_SINGLEWORD_NOGLOB_COND, rename o_glob->perform_glob
+ other small tweaks to comments and such

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 10:22:13 +02:00
Denys Vlasenko
96f064d416 shell: remove lash and bbsh
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 10:18:21 +02:00
Denys Vlasenko
b36abf2dfc hush: big reordering: move parser functions to the beginning. no code changes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:50:59 +02:00
Denys Vlasenko
38292b68c9 hush: rename o_quoted to has_quoted_part; small code shrink
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:49:40 +02:00
Denys Vlasenko
f2dc20c2d5 hush: move variable expansion into a separate function. No logic changes
function                                             old     new   delta
expand_one_var                                         -    1551   +1551
expand_vars_to_list                                 2833    1175   -1658
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 1551/-1658)       Total: -107 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:48:11 +02:00
Denys Vlasenko
36f774a0cd hush: add support for ${var/pattern/repl}, conditional on bash compat
function                                             old     new   delta
expand_vars_to_list                                 2386    2833    +447
expand_string_to_string                               69     110     +41
parse_dollar                                         681     721     +40
hush_main                                            963     945     -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 528/-18)           Total: 510 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:47:58 +02:00
Denys Vlasenko
701e127f7d hush: optimize #[#] and %[%] for speed. size -2 bytes.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-04 21:21:07 +02:00
Denys Vlasenko
e298ce69ba hush: fix handling of backslashes in variable assignment
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-04 19:52:44 +02:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00
Denys Vlasenko
7783248eaa *: s/xatoi_u/xatoi_positive/g - I got bored of mistyping xatoi_u as xatou_i
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-12 14:14:45 +02:00
Denys Vlasenko
f3ea792bad *: mass cosmetic removal of extra empty lines. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-26 01:06:14 +02:00
Alexander Shishkin
ccb9771861 ash: fix $! value when traps are set
Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-25 13:07:39 +02:00
Denys Vlasenko
6adf2aad38 hush: move msh/lash config into hush.c, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 19:26:38 +02:00
Denys Vlasenko
771f1995a9 ash: move config stuff into ash.c, no code chages
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 14:31:34 +02:00
Denys Vlasenko
29082231d0 hush: fix multimple dependent variable expansion cases
function                                             old     new   delta
get_local_var_value                                  100     171     +71
expand_assignments                                    46      76     +30
reset_traps_to_defaults                              229     238      +9
maybe_set_to_sigexit                                  47      50      +3
init_sigmasks                                        211     214      +3
builtin_trap                                         462     465      +3
expand_vars_to_list                                 2412    2408      -4
run_pipe                                            1568    1533     -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/2 up/down: 119/-39)            Total: 80 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 13:52:32 +02:00
Denys Vlasenko
202a2d1219 hush: make set -x support optional
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 12:36:14 +02:00
Denys Vlasenko
3f5fae0772 hush: add support for set -x
function                                             old     new   delta
run_pipe                                            1442    1568    +126
dump_cmd_in_x_mode                                     -     126    +126
builtin_trap                                         441     462     +21
pseudo_exec_argv                                     171     187     +16
reset_traps_to_defaults                              214     229     +15
check_and_run_traps                                  227     232      +5
hush_exit                                             98     101      +3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 6/0 up/down: 312/0)             Total: 312 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 12:35:35 +02:00
Denys Vlasenko
b3389de04b hush: fix typo in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-15 12:33:37 +02:00
Denys Vlasenko
8fa1f5d543 hush: fix faloout from previous commit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-15 08:18:46 +02:00
Denys Vlasenko
889550b36b hush: make pun_pipe loop clearer; fix "cmd | var=cmd | cmd" handling
function                                             old     new   delta
free_strings                                           -      38     +38
pseudo_exec_argv                                     161     171     +10
free_pipe                                            227     205     -22
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 48/-22)             Total: 26 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-14 19:01:25 +02:00
Denys Vlasenko
9297dbc9d2 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-05 21:37:12 +02:00
Pascal Bellard
926031b764 *: introduce and use xfork() and xvfork()
function                                             old     new   delta
launch_helper                                        170     169      -1
setup_heredoc                                        312     302     -10
handle_dir_common                                    367     354     -13
expand_vars_to_list                                 2456    2443     -13
open_transformer                                      89      74     -15
data_extract_to_command                              439     423     -16
do_ipaddr                                           1406    1389     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-85)             Total: -85 bytes

Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-04 15:32:38 +02:00
Denys Vlasenko
1fcbff2fac build system: do not rebuild ash and hush on any change to any .c file
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-26 02:40:08 +02:00
Dan Fandrich
fdd7b566ec A few minor portability improvements
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-19 20:03:15 +02:00
Denys Vlasenko
729ecb87bf bbconfig: make it independent from printf functions
function                                             old     new   delta
full_write2_str                                        -      25     +25
full_write1_str                                        -      25     +25
clear_main                                            21      20      -1
telnet_main                                         1488    1477     -11
getty_main                                          1932    1918     -14
full_write22_str                                      25       -     -25
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/3 up/down: 50/-51)             Total: -1 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-07 14:14:26 +02:00
Denys Vlasenko
599ae1eb9f shell: consolidate builtin_foo.? into shell_common.?; delete obsolete shells
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-23 17:49:50 +02:00
Denys Vlasenko
8391c4800c hush: trivial code shrink
function                                             old     new   delta
static_get                                            26      22      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 17:50:43 +02:00
Denys Vlasenko
2e48d536ce hush: reduce #ifdef forest a bit, rename handle_dollar -> parse_dollar
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 17:30:39 +02:00
Denys Vlasenko
5ae8f1cdbe hush: fix hush -c 'echo $0' - was showing empty string
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 06:32:11 +02:00
Denys Vlasenko
e85248afa2 hush: fix segfault in ${?:N:M}
function                                             old     new   delta
expand_vars_to_list                                 2374    2409     +35
builtin_umask                                        132     133      +1
builtin_exit                                          47      48      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 37/0)               Total: 37 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 06:20:26 +02:00
Denys Vlasenko
8a33679694 hush: fix "hush -c 'echo $#'" showing -1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 06:05:02 +02:00
Denys Vlasenko
1e811b1231 hush: support ${var:EXPR:EXPR}!
function                                             old     new   delta
handle_dollar                                        574     681    +107
expand_and_evaluate_arith                              -      77     +77
expand_vars_to_list                                 2302    2374     +72
add_till_closing_bracket                             359     368      +9
builtin_exit                                          48      47      -1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 265/-1)            Total: 264 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 03:12:29 +02:00
Denys Vlasenko
ddc62f64ba hush: fix a nommu todo in recent commits
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 00:53:32 +02:00
Denys Vlasenko
a6ad397ea9 hush: fix more obscure ${var%...} cases
function                                             old     new   delta
add_till_closing_paren                               313     359     +46
builtin_exit                                          48      47      -1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 00:26:06 +02:00
Denys Vlasenko
7436950a75 hush: fix a=abc; c=c; echo ${a%${c}}
function                                             old     new   delta
expand_vars_to_list                                 2229    2302     +73
add_till_closing_paren                               286     313     +27
handle_dollar                                        623     574     -49
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 100/-49)            Total: 51 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 19:52:01 +02:00
Denys Vlasenko
3f78cec347 hush: handle expansions in ${var?expanded_word} constructs
function                                             old     new   delta
expand_vars_to_list                                 2209    2229     +20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 17:54:46 +02:00
Denys Vlasenko
349ef96bb5 hush: reorganized TODO comment at top
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 15:46:24 +02:00
Denys Vlasenko
214b8ca3dc hush: add a list of unsupported builtins
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 15:35:44 +02:00
Denys Vlasenko
73e013fca7 hush: handle ${var:NUM:} too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 15:24:12 +02:00
Denys Vlasenko
4f2c59b267 hush: remove extra comparison from prev commit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 01:25:16 +02:00
Denys Vlasenko
4d8e5fdc1d hush: optional support for ${var:N:M} bashism
function                                             old     new   delta
expand_vars_to_list                                 1999    2183    +184
handle_dollar                                        682     623     -59

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 01:15:42 +02:00
Denys Vlasenko
53b513331a hush: explain various parameter expansion ops in comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 21:46:45 +02:00
Denys Vlasenko
ee0775dd13 hush: small code shrink
function                                             old     new   delta
expand_vars_to_list                                 2012    1999     -13

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 16:37:53 +02:00
Denys Vlasenko
e3be7842be hush: shrink variable expansion code
function                                             old     new   delta
expand_vars_to_list                                 2164    2012    -152

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 16:27:42 +02:00
Denys Vlasenko
cddbb610cb hush: fix var=exit 2 not setting $? to 2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 14:27:09 +02:00
Denys Vlasenko
44c86ce5d7 hush: code shrink
text    data     bss     dec     hex filename
 843121     453    6828  850402   cf9e2 busybox_old
 843108     453    6828  850389   cf9d5 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 04:22:55 +02:00
Denys Vlasenko
b131ccec9c hush: support "cd -- DIR" and such
function                                             old     new   delta
skip_dash_dash                                         -      33     +33
builtin_exit                                          43      48      +5
builtin_umask                                        121     125      +4
builtin_shift                                        115     119      +4
builtin_cd                                            71      75      +4
builtin_wait                                         271     274      +3
builtin_source                                       171     174      +3
builtin_exec                                          57      60      +3
builtin_eval                                          46      45      -1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 7/1 up/down: 59/-1)              Total: 58 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 03:39:43 +02:00
Denys Vlasenko
e66cf821cf ash,hush: make bare "." set exitcode to 2
function                                             old     new   delta
dotcmd                                               300     305      +5
builtin_source                                       176     171      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 09:12:53 +02:00
Denys Vlasenko
adc0e20892 hush: update bash compat todo comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 18:56:58 +02:00
Denys Vlasenko
82731b4b7a ash,hush: make "source" a synonym for . if bash compat is on
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 17:49:52 +02:00
Denys Vlasenko
3227d3f982 hush: fix hush-bugs/parse_err.tests
function                                             old     new   delta
parse_stream                                        2325    2339     +14
builtin_umask                                        121     123      +2
builtin_type                                         116     114      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 09:49:47 +02:00
Denys Vlasenko
8806d64acd hush: mention PPID, RANDOM support
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-16 02:36:18 +02:00
Denys Vlasenko
651a2697f7 *: merge some common strings
text   data    bss    dec    hexfilename
 838650   8009      0 846659  ceb43busybox_old
 838519   8009      0 846528  ceac0busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-23 16:25:17 +01:00
Denys Vlasenko
1497484839 ash,hush: make it possible to build them individually
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-23 01:08:26 +01:00
Denys Vlasenko
f3c742f925 hush: use ash's ulimit builtin; make it more more bash0like while at it
Based on a patch by Tobias Klauser <tklauser@distanz.ch>

function                                             old     new   delta
shell_builtin_ulimit                                   -     498    +498
limits_tbl                                            33      88     +55
ulimit_opt_string                                      -      38     +38
bltins1                                              288     300     +12
limits_name                                          127       -    -127
ulimitcmd                                            415       7    -408
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 2/1 up/down: 603/-535)           Total: 68 bytes
   text    data     bss     dec     hex filename
 839229     453    6828  846510   ceaae busybox_old
 839423     453    6828  846704   ceb70 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-06 20:12:00 +01:00
Denys Vlasenko
14a917eaab hush: note a FIXME
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-02-08 03:04:22 +01:00
Denys Vlasenko
17323a6245 hush: more "greppable" field names. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-28 01:57:05 +01:00
Denys Vlasenko
3581c62515 whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-25 13:39:24 +01:00
Denys Vlasenko
6b01b71e83 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-24 22:52:21 +01:00
Denys Vlasenko
25d9b91d94 shell/read: check that variable names are sane
function                                             old     new   delta
shell_builtin_read                                  1000    1055     +55
parse_command                                       1460    1463      +3
builtin_umask                                        121     123      +2
is_well_formed_var_name                               73      66      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-13 18:22:35 +01:00
Denys Vlasenko
03dad22f8a hush: use ash's read builtin
function                                             old     new   delta
shell_builtin_read                                     -    1000   +1000
set_local_var_from_halves                              -      24     +24
setvar2                                                -       7      +7
...
popstring                                            140     134      -6
ash_main                                            1375    1368      -7
setvar                                               184     174     -10
arith_set_local_var                                   36       -     -36
builtin_read                                        1096     185    -911
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 5/23 up/down: 1038/-1007)        Total: 31 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 23:29:57 +01:00
Denys Vlasenko
6c93b24ce9 hush: fix potential buffer overflow on NOMMU
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 19:28:10 +01:00
Denys Vlasenko
e89a241b9e hush: fix subshell.tests failure on NOMMU
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 15:19:31 +01:00
Denys Vlasenko
b70cef71eb hush: two NOMMU fixes for bugs 877 and 883
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 13:45:45 +01:00
Denys Vlasenko
385cc59117 hush: plug a memory leak
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 06:47:39 +01:00
Denys Vlasenko
a4899efd03 hush: fix exitcodes of killed processes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-04 11:37:09 +01:00
Denys Vlasenko
c270454f8f fix fallout from isprint() changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-20 19:14:19 +01:00
Denys Vlasenko
f3e2818895 hush: improve HUSH_BRACE_EXP code (still disabled). ~0 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-17 03:35:31 +01:00
Denys Vlasenko
160746b603 tweak in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-16 05:51:18 +01:00
Denys Vlasenko
5b2db97703 hush: initial stab at brace expansion support
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-16 05:49:36 +01:00
Denys Vlasenko
d8389ad760 hush: fix handling of words with braces. +65 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-16 03:18:46 +01:00
Denys Vlasenko
00243b0a1a hush: fix exit code propagation from cmd. +45 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-16 02:00:03 +01:00
Denys Vlasenko
a7ccdeef39 libbb: added xfdopen_for_read/write
function                                             old     new   delta
xfdopen_helper                                         -      40     +40
logdir_open                                         1163    1184     +21
process_stdin                                        433     443     +10
xfdopen_for_write                                      -       9      +9
doCommands                                          2465    2474      +9
patch_main                                          1214    1222      +8
bbunpack                                             457     465      +8
xfdopen_for_read                                       -       7      +7
scan_tree                                            258     262      +4
xstrtoul_range_sfx                                   230     231      +1
sendmail_main                                        957     955      -2
passwd_main                                         1027    1023      -4
parse                                                969     964      -5
test_main                                            253     247      -6
sed_main                                             655     649      -6
dos2unix_main                                        437     429      -8
fbsplash_main                                        950     938     -12
handle_dir_common                                    371     354     -17
expand_vars_to_list                                 2197    2169     -28
update_passwd                                       1275    1246     -29
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 7/10 up/down: 117/-117)           Total: 0 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-15 23:28:11 +01:00
Denys Vlasenko
647553a4fc hush: wait for cmd to complete, and immediately store its exitcode in $?
function                                             old     new   delta
expand_vars_to_list                                 2129    2197     +68

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-15 19:58:19 +01:00
Denys Vlasenko
8131eea3dc *: introduce and use ffulsh_all()
function                                             old     new   delta
buffer_fill_and_print                                179     196     +17
fflush_all                                             -       9      +9
spawn                                                 87      92      +5
rtcwake_main                                         455     453      -2
...
alarm_intr                                            93      84      -9
readcmd                                             1072    1062     -10
bb_ask                                               345     333     -12
more_main                                            845     832     -13
flush_stdout_stderr                                   42      23     -19
xfflush_stdout                                        27       -     -27
flush_stderr                                          30       -     -30
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/50 up/down: 31/-397)         Total: -366 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-02 14:19:51 +01:00
Denys Vlasenko
c1947f18f5 build failure fix and some cosmetics
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-23 01:30:26 +02:00
Denys Vlasenko
3ef4f77620 hush: fix exec builtin in a better way (+ "glob in exec" bug fixed)
function                                             old     new   delta
execvp_or_die                                          -      50     +50
static.pseudo_null_str                                 3       -      -3
builtin_exec                                          83      57     -26
pseudo_exec_argv                                     200     163     -37
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 50/-66)            Total: -16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-19 23:09:06 +02:00
Denys Vlasenko
aaa22d2493 hush: use configured max line length, not BUFSIZE from libc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-19 16:34:39 +02:00
Denys Vlasenko
3b3ccdc5bc hush: remove superfluous assignment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-19 13:24:07 +02:00
Denys Vlasenko
8bc7f2c5aa hush: make it compile again :/
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-19 13:20:52 +02:00
Denys Vlasenko
c0836530f1 hush: cosmetics. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-19 13:13:06 +02:00
Denys Vlasenko
f37eb3999b hush: fix handling of empty arguments
function                                             old     new   delta
builtin_exec                                          25      83     +58
parse_stream                                        2242    2261     +19
run_pipe                                            1782    1787      +5
static.pseudo_null_str                                 -       3      +3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 85/0)               Total: 85 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-18 11:46:35 +02:00
Mike Frysinger
28736c36ca hush: handle empty execs
Sometimes variable expansions yield empty strings, and if they happen to
be a command someone wants to run like `$foo`, then hush currently
segfaults.  So handle `` and $().

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-10-18 01:15:36 -04:00
Mike Frysinger
4ebc76c8a2 hush: add a printf builtin
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-10-15 03:33:31 -04:00
Mike Frysinger
ccb1959aa5 hush: unify handling of builtin applets
Saves about 10 bytes for each additional builtin applet.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-10-15 03:33:31 -04:00
Denys Vlasenko
76ace254e1 ash,hush: fix $RANDOM in children being repeated
function                                             old     new   delta
next_random                                           46      68     +22
forkshell                                            248     263     +15
expand_vars_to_list                                 2118    2131     +13
run_pipe                                            1775    1782      +7
popstring                                            134     140      +6
builtin_umask                                        123     121      -2
ash_main                                            1356    1336     -20
get_local_var_value                                  125     104     -21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/3 up/down: 63/-43)             Total: 20 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-12 15:25:01 +02:00
Denys Vlasenko
8c66a9d07a hush: shrink $RANDOM support
function                                             old     new   delta
get_local_var_value                                  104     125     +21
hush_main                                           1024     983     -41

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-11 02:15:49 +02:00
Denys Vlasenko
cbe0b7fb59 hush: fix cut-n-paste error in last commit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 22:00:58 +02:00
Denys Vlasenko
20b3d144e9 hush: add support for $RANDOM. If on:
function                                             old     new   delta
hush_main                                            983    1024     +41
get_local_var_value                                   72     104     +32
block_signals                                        155     161      +6
reset_traps_to_defaults                              211     214      +3
builtin_wait                                         268     271      +3
pseudo_exec_argv                                     198     200      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 87/0)               Total: 87 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 20:59:39 +02:00
Denys Vlasenko
dea478855f hush: support $PPID
function                                             old     new   delta
get_local_var_value                                   33      72     +39
hush_main                                            951     983     +32
block_signals                                        152     155      +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 74/0)               Total: 74 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 15:40:49 +02:00
Denys Vlasenko
a7bb3c1396 *: code shrink via NOINLINE
function                                             old     new   delta
expand_vars_to_list                                    -    2118   +2118
lzo1x_optimize                                         -    1429   +1429
run_pipe                                             358    1775   +1417
arith_apply                                            -    1335   +1335
mainQSort3                                             -    1198   +1198
logdir_open                                            -    1163   +1163
rewrite                                                -    1039   +1039
dump_identity                                          -     987    +987
do_shm                                                 -     884    +884
cpio_o                                                 -     863    +863
cpio_main                                           1450     560    -890
ipcs_main                                           3442    2523    -919
bb_dump_dump                                        2611    1488   -1123
process_dev                                         4572    3405   -1167
logdirs_reopen                                      1308      86   -1222
arith                                               2084     707   -1377
mainSort                                            2622    1202   -1420
do_lzo_compress                                     2276     799   -1477
run_list                                            2491     943   -1548
expand_variables                                    2280     135   -2145
------------------------------------------------------------------------------
(add/remove: 9/0 grow/shrink: 1/10 up/down: 12433/-13288)    Total: -855 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-08 12:28:08 +02:00
Denys Vlasenko
c34c033c42 ash,hush: share string
function                                             old     new   delta
optschanged                                          133     139      +6
hush_main                                            997     982     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 6/-15)              Total: -9 bytes
   text   data    bss    dec    hexfilename
 823160    445   7668 831273  caf29busybox_old
 823102    445   7668 831215  caeefbusybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-29 12:25:30 +02:00
Denys Vlasenko
e74aaf9385 ash,hush: make trap output short signal names, without SIG prefix
function                                             old     new   delta
evalvar                                             1373    1371      -2
builtin_trap                                         457     441     -16
trapcmd                                              260     236     -24

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-27 02:05:45 +02:00
Denys Vlasenko
67f7186403 hush: do not reset to default "" traps in subshell
function                                             old     new   delta
reset_traps_to_defaults                              164     211     +47
builtin_umask                                        123     121      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-25 14:21:06 +02:00
Denys Vlasenko
4ea0ca8193 hush: document a TODO. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-25 12:58:37 +02:00
Denys Vlasenko
7188540257 hush: small speed optimization. +10 bytes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-24 01:44:13 +02:00
Denys Vlasenko
2f7894b1bb ash,hush: fix trap reporting: s/SIGEXIT/EXIT/
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-24 01:43:21 +02:00
Denys Vlasenko
606291beab *: more portability fixes by Dan Fandrich
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-23 23:15:43 +02:00
Denys Vlasenko
91836baf85 hush: fix trap
function                                             old     new   delta
expand_variables                                    2217    2280     +63
static.argv                                            -       8      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-23 01:46:19 +02:00
Denys Vlasenko
69b1cef921 hush: better wording in comments. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-21 10:21:44 +02:00
Denys Vlasenko
27726cb6aa hush: make memleak debugging more robust
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-12 14:48:33 +02:00
Denys Vlasenko
873273da94 hush: code shrink by Dan Fandrich (dan AT coneharvesters.com)
function                                             old     new   delta
find_function_slot                                     -      47     +47
run_list                                            2508    2491     -17
find_function                                         40       8     -32
builtin_unset                                        227     165     -62

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-12 14:47:41 +02:00
Denys Vlasenko
90a9904e9e remove some GNUisms. by Dan Fandrich (dan AT coneharvesters.com)
function                                             old     new   delta
logdirs_reopen                                      1310    1308      -2
read_line_input                                     4757    4753      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6)               Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-06 02:36:23 +02:00
Denys Vlasenko
6db4784d27 hush: export PWD
function                                             old     new   delta
set_pwd_var                                            -      36     +36
hush_main                                            941     951     +10
evalvar                                             1365    1363      -2
ash_main                                            1364    1362      -2
builtin_cd                                            75      72      -3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/3 up/down: 46/-7)              Total: 39 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-05 20:15:17 +02:00
Denys Vlasenko
1cc4b13917 msh: aliased to hush
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-21 00:05:51 +02:00
Denys Vlasenko
0793491ff8 hush: enable "lash is deprecated, please use hush instead" message
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-20 03:40:04 +02:00
Denys Vlasenko
a67a9627d0 hush: do not process options after non-option args
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-20 03:38:58 +02:00
Denys Vlasenko
cbfe6ad4c6 hush: fix \<newline> handling on NOMMU
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-12 19:47:44 +02:00
Denys Vlasenko
19679784c0 hush tests: remove the requirement that .config is in ../..
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-12 14:53:44 +02:00
Denys Vlasenko
9038d6f8f5 remove trailing whitespace
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-15 20:02:19 +02:00
Denys Vlasenko
82a6fb3ea6 ash: fix . builtin
Also, move [[ ]] comment to test.c and expand it

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-14 19:42:12 +02:00
Denys Vlasenko
77539190ab added comments about [[ ]] to ash and hush. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-10 14:09:48 +02:00
Denys Vlasenko
9ca656b149 hush: add HUSH_BASH_COMPAT, make [[ special handling depend on it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-10 13:39:35 +02:00
Denys Vlasenko
9d617c44d2 hush: specially handle [[ - suppress globbing & multiword expansion
It's a bashism, but is surprisingly easy to do and costs very little code.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-09 18:40:52 +02:00
Denys Vlasenko
764b2f0ec0 hush: drop REDIRECT_INVALID; other minor tweaks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-07 16:05:04 +02:00
Denys Vlasenko
df5131cf3d hush: fix a segfault in export builtin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-07 16:04:17 +02:00
Denys Vlasenko
d6b05eb9c2 hush: make builtins work in pipes (eval ... | ...) on NOMMU
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-06 20:59:55 +02:00
Denys Vlasenko
d5f1b1bbe0 *: add FAST_FUNC to function ptrs where it makes sense
function                                             old     new   delta
evalcommand                                         1195    1209     +14
testcmd                                                -      10     +10
printfcmd                                              -      10     +10
echocmd                                                -      10     +10
func_exec                                            270     276      +6
echo_dg                                              104     109      +5
store_nlmsg                                           85      89      +4
pseudo_exec_argv                                     195     198      +3
dotcmd                                               287     290      +3
machtime_stream                                       29      31      +2
discard_stream                                        24      26      +2
argstr                                              1299    1301      +2
killcmd                                              108     109      +1
evalfor                                              226     227      +1
daytime_stream                                        43      44      +1
run_list                                            2544    2543      -1
lookupvar                                             62      61      -1
ipaddr_modify                                       1310    1309      -1
...
parse_stream                                        2254    2245      -9
evalpipe                                             356     347      -9
collect_if                                           210     197     -13
read_opt                                             869     851     -18
handle_dollar                                        681     658     -23
print_addrinfo                                      1342    1303     -39
iterate_on_dir                                       156      59     -97
print_route                                         1709    1609    -100
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 12/130 up/down: 74/-767)       Total: -693 bytes
   text    data     bss     dec     hex filename
 841748     467    7872  850087   cf8a7 busybox_old
 841061     467    7872  849400   cf5f8 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-05 12:06:05 +02:00
Denys Vlasenko
0821801349 hush: document a TODO in export builtin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-03 14:43:56 +02:00
Denys Vlasenko
6f22624a91 hush: fix a case when backgrounded cmd makes shell hang
Signed-off-by: Bayram Kurumahmut <kbayram@ubicom.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-03 14:37:30 +02:00
Denys Vlasenko
295fef80bc hush: add support for local builtin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-03 12:47:26 +02:00
Mike Frysinger
6a46ab8b8f hush: unify syntax_error_unterm_{ch,str} a bit
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 14:16:43 -04:00
Mike Frysinger
ef3e7fdd3b hush: push down expansion var in handle_dollar()
Declare the variable in the scope it is used rather than the entire
function scope so it's obvious it is only used there.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 14:16:43 -04:00
Mike Frysinger
dc3bc40578 hush: add support for special vars in braces
Some people like to use ${?} rather than $?, so make sure we support all
the special single char vars that use this form.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 14:16:43 -04:00
Denys Vlasenko
28a105d867 nc, hush: cosmetic cleanups, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-01 11:26:30 +02:00
Denys Vlasenko
4b7db4f2ca read_key: drop optimization where we read 3 bytes at once
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-29 10:39:06 +02:00
Denys Vlasenko
171932d7ca hust: trivial simplification in builtin_type
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-28 17:07:22 +02:00
Denys Vlasenko
e640cb4ad1 hush: fix bug 353 (wrong handling of \x in assignments)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-28 16:49:11 +02:00
Denys Vlasenko
5d7cca2090 hush: optimize type builtin a bit more
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-28 09:58:43 +02:00
Denys Vlasenko
dd6b211921 hush: optimize type builtin a bit
function                                             old     new   delta
builtin_type                                         130     125      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-28 09:45:50 +02:00
Mike Frysinger
93cadc2fdd hush: implement type
Implement support for the POSIX `type` command.  Only POSIX stuff is
supported here, no bash extensions like -p or -P.

In the process, split the $PATH searching code out of builtin_source() and
into its own find_in_path() function so we don't duplicate it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-27 17:06:25 -04:00
Denys Vlasenko
673e945052 hush: remove outdated TODO and superfluous macro; fix compile breakage
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-27 14:39:35 +02:00
Denys Vlasenko
68759edb6e hush: tweak comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-26 14:39:41 +02:00
Denys Vlasenko
e2df5f46d0 hush: rename last_waitpid_was_0 to we_have_children
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-26 14:34:10 +02:00
Denys Vlasenko
8d7be232a3 hush: fix SIGCHLD counting code, but keep it disabled for now.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-25 16:38:32 +02:00
Denys Vlasenko
e9bda90e54 hush: fix problems with case in subshells and with "case esac"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-23 16:50:07 +02:00
Mike Frysinger
38478a600f hush: fix build failure when jobs are disabled
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reported-by: Thomas Chou <thomas@wytron.com.tw>
2009-05-20 04:48:06 -04:00
root
6245202e7f hush: small fix for unset -f on NOMMU.
Signed-off-by: root <root@localhost.localdomain>
2009-05-04 12:00:19 +02:00
Denys Vlasenko
acdc49c073 hush: add more complex case to leak testcase, fix found breakage
function                                             old     new   delta
unset_local_var_len                                    -     167    +167
run_list                                            2350    2457    +107
set_vars_and_save_old                                  -      87     +87
free_pipe                                            207     227     +20
builtin_unset                                        220     229      +9
builtin_exit                                          49      47      -2
free_strings_and_unset                                53       -     -53
set_vars_all_and_save_old                             87       -     -87
unset_local_var                                      168       -    -168
------------------------------------------------------------------------------
(add/remove: 2/3 grow/shrink: 3/1 up/down: 390/-310)           Total: 80 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-04 01:58:10 +02:00
Denys Vlasenko
cb6ff25afe hush: fix bug where in "var=val func" var's value is not visible in func
function                                             old     new   delta
unset_local_var                                        -     168    +168
set_vars_all_and_save_old                              -      87     +87
get_ptr_to_local_var                                   -      77     +77
free_strings_and_unset                                 -      53     +53
builtin_export                                       266     274      +8
get_local_var_value                                   31      33      +2
putenv_all                                            27       -     -27
free_strings_and_unsetenv                             53       -     -53
get_local_var                                         68       -     -68
run_list                                            2475    2350    -125
builtin_unset                                        380     220    -160
------------------------------------------------------------------------------
(add/remove: 4/3 grow/shrink: 2/2 up/down: 395/-433)          Total: -38 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-04 00:14:30 +02:00
Denys Vlasenko
e19e1935a3 hush: fix \<newline> handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-03 02:15:18 +02:00
Denys Vlasenko
b1cfc45376 hush: fix handling of unterminated subshell: (<eof>. Fixes bug 229.
function                                             old     new   delta
syntax_error_unexpected_ch                            31      41     +10
parse_stream                                        2184    2191      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-02 17:18:34 +02:00
Denys Vlasenko
1dd6cf8677 hush: fix multiple redirections of the same fd (bug 227)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-02 14:17:31 +02:00
Denys Vlasenko
54e0843e7d hush: make . cmd search $PATH
function         old     new   delta
builtin_source   128     249    +121

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-02 02:34:19 +02:00
Denys Vlasenko
690ad2426e git commit test
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-04-30 21:24:24 +02:00
Denis Vlasenko
c8653f62f2 hush: make it possible to have interactive shell on non-ctty.
init=/bin/hush: shows prompt, history works, etc.

function                                             old     new   delta
hush_main                                            888     925     +37
block_signals                                        139     152     +13
builtin_fg_bg                                        284     293      +9
checkjobs_and_fg_shell                                35      41      +6
sigexit                                               65      66      +1
reset_traps_to_defaults                              165     164      -1
parse_stream                                        2200    2184     -16
run_list                                            2502    2475     -27
getpgid                                               35       -     -35
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 5/3 up/down: 66/-79)            Total: -13 bytes
2009-04-27 23:29:14 +00:00
Denis Vlasenko
28e67966f3 hush: make getopt32 usable in builtins. use it in unset.
more uses are expected in the future.

function                                             old     new   delta
getopt32                                            1356    1393     +37
builtin_export                                       256     266     +10
builtin_unset                                        418     380     -38
2009-04-26 23:22:40 +00:00
Denis Vlasenko
572930027d hush: nommu fix for function passing 2009-04-26 20:06:14 +00:00
Denis Vlasenko
5b7589eb27 hush: fix SEGV in % expansion
function                                             old     new   delta
expand_variables                                    2203    2217     +14
2009-04-26 11:25:19 +00:00
Mike Frysinger
26cf2831d7 do not tell people they can enter "help" if help has actually been disabled 2009-04-24 06:40:30 +00:00
Mike Frysinger
67c1c7b456 use get_local_var_value() rather than getenv() when working with PS1/PS2/HOME, respect the PS2 env var, and make sure that the prompt changes whenever PS1/PS2 changes so we dont have to re-exec the shell to get a changed prompt 2009-04-24 06:26:18 +00:00
Denis Vlasenko
f9d4fc3cf8 switch_root: improve behavior on error; improve help text
*: make "can't execute '%s'" message uniform
2009-04-21 20:40:51 +00:00
Denis Vlasenko
950bd72966 hush: speed up set_local_var
function                                             old     new   delta
set_local_var                                        265     290     +25
2009-04-21 11:23:56 +00:00
Denis Vlasenko
5e34ff29bc *: mass renaming of USE_XXXX to IF_XXXX
and SKIP_XXXX to IF_NOT_XXXX - the second one was especially
badly named. It was not skipping anything!
2009-04-21 11:09:40 +00:00
Denis Vlasenko
ad4bd0548a hush: export -n support
function                                             old     new   delta
builtin_export                                       206     256     +50
set_local_var                                        248     265     +17
expand_variables                                    2204    2203      -1
2009-04-20 22:04:21 +00:00
Denis Vlasenko
8c64e033c0 hush: fix stdin of backgrounded pipe
function                                             old     new   delta
run_list                                            2450    2502     +52
2009-04-20 00:34:01 +00:00
Denis Vlasenko
dcd78c4d0f hush: fix "export not_yet_defined_var", fix parsing of "cmd | }"
corner case; improve hush_leaktool.sh;
 fix some false positives in testsuite

function                                             old     new   delta
builtin_export                                       191     206     +15
parse_stream                                        2196    2200      +4
2009-04-19 23:07:51 +00:00
Denis Vlasenko
9f8d938172 same as previous, but -100 bytes 2009-04-19 14:03:11 +00:00
Denis Vlasenko
bf25fbccb9 hush: fix handling of } which is not a closing one in { cmd; }
function                                             old     new   delta
parse_stream                                        2176    2302    +126
builtin_unset                                        381     387      +6
2009-04-19 13:57:51 +00:00
Mike Frysinger
885b6f29ae fix build errors when function support is turned off 2009-04-18 21:04:25 +00:00
Denis Vlasenko
6008d8a3cc hush: fix thinko in error msg 2009-04-18 13:05:10 +00:00
Denis Vlasenko
38e626df4d hush: fix "trap -- handler SIGs..."; escape handlers in "trap" output 2009-04-18 12:58:19 +00:00
Denis Vlasenko
730106767e hush: fix thinko in unset_func 2009-04-18 11:25:18 +00:00
Denis Vlasenko
40e84374ec hush: implement unset -f; beautify the handling of signal-killed pipe
four TODOs are gone

function                                             old     new   delta
builtin_unset                                        271     364     +93
checkjobs                                            394     428     +34
builtin_exit                                          49      47      -2
2009-04-18 11:23:38 +00:00
Denis Vlasenko
eb85849b50 hush: deal with umask TODO (symbolic modes)
function                                             old     new   delta
builtin_umask                                         79     125     +46
2009-04-18 02:06:54 +00:00
Denis Vlasenko
6b9e05392b hush: implement proper SIGHUP handling
function                                             old     new   delta
check_and_run_traps                                  164     229     +65
insert_bg_job                                        376     366     -10
hush_main                                            937     927     -10
2009-04-18 01:23:21 +00:00
Denis Vlasenko
7b9e5c57ae builtin_return's parameter is not unused 2009-04-17 23:53:15 +00:00
Denis Vlasenko
3d40d8e655 hush: return builtin by Bayram Kurumahmut (kbayram AT ubicom.com)
~+200 bytes
2009-04-17 23:44:18 +00:00
Denis Vlasenko
270b1c3f68 hush: set $n properly for "source" builtin
function                                             old     new   delta
restore_G_args                                         -      78     +78
save_and_replace_G_args                                -      64     +64
builtin_source                                        72     107     +35
run_list                                            2549    2367    -182
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/1 up/down: 177/-182)           Total: -5 bytes
2009-04-17 18:54:50 +00:00
Denis Vlasenko
4ea187fd62 hush: fix non-interactive response to pipe being stopped.
function                                             old     new   delta
checkjobs                                            380     394     +14
2009-04-17 14:35:43 +00:00
Denis Vlasenko
e4bd4f2cc8 hush: unblock TERM, INT, HUP in child shells too. 2009-04-17 13:52:51 +00:00
Denis Vlasenko
f8c1f02d2f hush: disallow "{echo hi; }" (require whitespace)
and "{ echo hi }" (require semicolon or &)

function                                             old     new   delta
parse_stream                                        2098    2176     +78
done_command                                          98      84     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 78/-14)             Total: 64 bytes
2009-04-17 11:55:42 +00:00
Denis Vlasenko
fa4ca7889e hush: add a TODO 2009-04-16 12:00:15 +00:00
Denis Vlasenko
bb929517a8 hush: fix "if { echo foo; } then { echo bar; } fi" parsing
function                                             old     new   delta
done_word                                            728     793     +65
parse_stream                                        2084    2098     +14
2009-04-16 10:59:40 +00:00
Denis Vlasenko
74a931ac9e hush: stop ignoring ^Z in child shells 2009-04-15 23:29:44 +00:00
Denis Vlasenko
c4ada79343 hush: remove old disabled ^Z handling 2009-04-15 23:29:00 +00:00
Denis Vlasenko
41ddecd9ed hush: fix heredoc_huge.tests broken in last commits 2009-04-15 21:58:14 +00:00
Denis Vlasenko
c376db332c hush: remove TODO comment itself :) 2009-04-15 21:49:48 +00:00
Denis Vlasenko
27014ed5cb hush: deal with a TODO: move argv_from_re_execing out of globals
function                                             old     new   delta
generate_stream_from_string                          156     165      +9
setup_heredoc                                        312     320      +8
re_execute_shell                                     387     391      +4
pseudo_exec_argv                                     129     133      +4
run_pipe                                            1790    1783      -7
clean_up_after_re_execute                             30       -     -30
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 4/1 up/down: 25/-37)            Total: -12 bytes
2009-04-15 21:48:23 +00:00
Denis Vlasenko
7f9593753a randomconfig fixes 2009-04-14 08:06:59 +00:00
Denis Vlasenko
2b2183a77d hush: make function support configurable 2009-04-13 14:23:12 +00:00
Denis Vlasenko
bc56974062 hush: pass functions to child shells on NOMMU
function                                             old     new   delta
new_function                                           -     123    +123
hush_main                                           1198    1262     +64
re_execute_shell                                     341     387     +46
run_pipe                                            1872    1790     -82
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/1 up/down: 233/-82)           Total: 151 bytes
2009-04-12 20:35:19 +00:00
Denis Vlasenko
c43430f1b9 hush: remove functions from TODOs 2009-04-11 11:07:22 +00:00
Denis Vlasenko
0701dca88c hush: improve debugging output 2009-04-11 10:38:47 +00:00
Denis Vlasenko
ed055214bb hush: fix "while...do f1() {a;}; f1; f1 {b;}; f1; done" bug 2009-04-11 10:37:10 +00:00
Denis Vlasenko
ce4acbbab6 hush: add function tests 2009-04-10 23:23:41 +00:00
Denis Vlasenko
6ba6f546ac hush: pass $n to functions
function                                             old     new   delta
run_pipe                                            1183    1325    +142
run_list                                            1219    1220      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 143/0)             Total: 143 bytes
2009-04-10 21:57:50 +00:00
Denis Vlasenko
c0ea329297 hush: fix a few thinkos in function support; make it work on NOMMU;
functions in child shells now even have $n passed to them! :)
 (in main shell it still doesn't work)
2009-04-10 21:22:02 +00:00
Denis Vlasenko
b7d8c0dbbd hush: first stab at function support. argv passing is not coded yet.
Only very rudimentary testing was done.
 With function support off, code growth is zero, with it on:

function                                             old     new   delta
run_list                                            2158    2339    +181
parse_stream                                        1929    2044    +115
find_builtin                                          24      67     +43
find_function                                          -      36     +36
file_get                                             244     264     +20
pseudo_exec_argv                                     145     160     +15
free_strings                                           -       7      +7
free_pipe                                            183     181      -2
done_word                                            735     728      -7
expand_variables                                    2227    2204     -23
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 5/3 up/down: 417/-32)           Total: 385 bytes
2009-04-10 19:05:43 +00:00
Denis Vlasenko
835fcfd33d hush: reinstate accidentally reverted comment fix 2009-04-10 13:51:56 +00:00
Denis Vlasenko
0b677d8337 hush: fix some TODOs. TODO in export builting: +250 bytes.
simplify unexpected EOF handling.

function                                             old     new   delta
builtin_export                                       117     374    +257
o_reset_to_empty_unquoted                              -      21     +21
parse_stream                                        1926    1929      +3
syntax_error_unterm_ch                                31      32      +1
handle_dollar                                        644     641      -3
parse_stream_dquoted                                 307     298      -9
add_till_backquote                                   106      97      -9
add_till_closing_paren                               303     286     -17
o_reset                                               21       -     -21
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 3/4 up/down: 282/-59)           Total: 223 bytes
2009-04-10 13:49:10 +00:00
Denis Vlasenko
1fd1ea4395 hush: tighten up "for" variable name check.
Add TODOs.
 Disable redir4.right part where we differ from bash.
 It is not a bug per standards.
 Add a few tests, one is in hush-bugs section:
 and_or_and_backgrounding.right. It will likely bite users
 in real world usage.
2009-04-10 12:03:20 +00:00
Denis Vlasenko
551bdfecb7 hush: fix typo in comment 2009-04-10 11:13:26 +00:00
Denis Vlasenko
ed7823738c fix segfault on syntax error code path 2009-04-10 00:45:02 +00:00
Denis Vlasenko
c96865f445 hush: readability improvements.
fix some more obscure bugs.
 a new redir4.tests is known to fail.
2009-04-10 00:20:58 +00:00
Mike Frysinger
57e746781c dont crash if the variable we do substitution on is not set 2009-04-09 23:00:33 +00:00
Denis Vlasenko
d68ae08cde hush: shrink and make more versatile error-reporting machinery
function                                             old     new   delta
syntax_error_unterm_ch                                 -      31     +31
syntax_error_unterm_str                                -      14     +14
parse_stream                                        2356    2361      +5
syntax_error_at                                       12      14      +2
syntax_error                                          25      27      +2
syntax_error_unterminated                             28       -     -28
expand_variables                                    2063    2031     -32
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 3/1 up/down: 54/-60)             Total: -6 bytes
   text    data     bss     dec     hex filename
  67278     197    3184   70659   11403 busybox_old
  67228     197    3184   70609   113d1 busybox_unstripped
2009-04-09 20:41:34 +00:00
Denis Vlasenko
05d3b7cc0d hush: deal with some easier TODOs
function                                             old     new   delta
is_well_formed_var_name                                -      87     +87
builtin_read                                          49      86     +37
die_if_script                                          -      31     +31
syntax_error_unterminated                              -      28     +28
syntax_error                                          26      51     +25
done_word                                            768     788     +20
syntax_error_at                                        -      12     +12
parse_stream_dquoted                                 320     328      +8
expand_variables                                    2064    2063      -1
run_list                                            1225    1220      -5
add_till_closing_paren                               308     303      -5
add_till_backquote                                   111     106      -5
handle_dollar                                        812     803      -9
parse_stream                                        2378    2356     -22
parse_redirect                                       408     372     -36
maybe_die                                             44       -     -44
is_assignment                                        215     134     -81
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 4/8 up/down: 248/-208)           Total: 40 bytes
2009-04-09 19:16:15 +00:00
Denis Vlasenko
1943aec2ec hush: plug the leak of expanded heredoc 2009-04-09 14:15:57 +00:00
Denis Vlasenko
efea9d2819 hush: fix EXIT trap recursion case; check redirection failures
function                                             old     new   delta                          
run_pipe                                            1299    1328     +29                          
hush_exit                                             90     102     +12                          
hush_main                                           1172    1179      +7                          
run_list                                            1226    1225      -1                          
------------------------------------------------------------------------------                    
(add/remove: 0/0 grow/shrink: 3/1 up/down: 48/-1)              Total: 47 bytes
2009-04-09 13:43:11 +00:00
Denis Vlasenko
f50caac53c hush: typo in comment 2009-04-09 01:40:15 +00:00
Denis Vlasenko
a2218dd862 hush: fix thinko in re_execute_shell; pass even less junk to heredoc helper
function                                             old     new   delta
re_execute_shell                                     284     314     +30
setup_heredoc                                        290     303     +13
execv                                                 23       -     -23
2009-04-09 01:39:02 +00:00
Denis Vlasenko
5c090a96f9 hush: more rodust detection of unterminated strings etc;
fix a case where we forget to copy `cmd` text;
 optimize nommu heredoc helper by not passing environment to it;
 add several tests

function                                             old     new   delta
add_till_closing_paren                               256     308     +52
parse_stream                                        2337    2378     +41
add_till_backquote                                    82     111     +29
re_execute_shell                                     269     284     +15
handle_dollar                                        802     812     +10
parse_stream_dquoted                                 316     320      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 151/0)             Total: 151 bytes
2009-04-08 21:51:33 +00:00
Denis Vlasenko
cc90f44402 hush: plug leak in run_pipe(). NOMMU only. 2009-04-08 16:40:34 +00:00