Commit Graph

1610 Commits

Author SHA1 Message Date
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
131ed3bcc9 update shell/README
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 12:56:14 +02:00
Denys Vlasenko
a0ec4f500c ash: eliminate 16 bytes in bss
text   data    bss    dec    hexfilename
 841423    441   7572 849436  cf61cbusybox_old
 841430    441   7556 849427  cf613busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 12:50:42 +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
40477e2fdb shell: make it possible to alias one of shells to "bash"
function                                             old     new   delta
packed_usage                                       27047   27054      +7
applet_names                                        2227    2232      +5
applet_main                                         1304    1308      +4
applet_nameofs                                       652     654      +2
applet_install_loc                                   163     164      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/0 up/down: 19/0)               Total: 19 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 02:09:45 +02:00
Denys Vlasenko
42c4b2e3b5 ash: fix var_leak.tests so that it actually catches the NOFORK bug
+ document the bug better

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 16:13:56 +02:00
Denys Vlasenko
c7f95d23f6 typo fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 15:52:23 +02:00
Denys Vlasenko
238bf187ba ash: fix bug which causes signal6.tests to fail
function                                             old     new   delta
trapcmd                                              271     277      +6
localcmd                                             277     275      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 15:49:07 +02:00
Denys Vlasenko
51b4a9e2f1 ash: fix var_leak testcase
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 14:35:20 +02:00
Denys Vlasenko
5e2d572381 ash: fix testsuite false positives
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 14:11:21 +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
0e81e488fd shell/README: describe special builtins
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 23:51:00 +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
cd10dc40e4 ash: fix ". empty_file" exitcode. +5 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 17:10:46 +02:00
Denys Vlasenko
786cce1871 fix false positive in signal5.tests
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 10:14:20 +02:00
Denys Vlasenko
82dd14a510 ash: use CONFIG_FEATURE_EDITING_MAX_LEN
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 10:10:01 +02:00
Denys Vlasenko
ef215558fa typo fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 09:55:13 +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
0f01b00d74 add two more tests which currently fail
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 04:57:55 +02:00
Denys Vlasenko
7c1ed9fbde ash: fix signal5.tests
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 04:42:40 +02:00
Denys Vlasenko
27ff681cfa ash: add two testcases for (not yet fixed) ash bugs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 02:56:18 +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
b367bb2a62 cttyhack: document the need to setsid
function                                             old     new   delta
packed_usage                                       26988   27057     +69

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-15 20:43:07 +02:00
Denys Vlasenko
5055a9f989 cttyhack: don't do anything if ctty is already available
function                                             old     new   delta
cttyhack_main                                        244     269     +25

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-14 04:08:20 +02:00
Colin Watson
3963d943f8 ash: refresh stack pointers after makestrspace in rmescapes
Without this, rmescapes sometimes returns random garbage while
performing parameter expansions such as ${foo#bar}, in the event that
the allocation of r happens to need to reallocate the stack and hence
invalidate str and p.  I'd love to provide a test case but unfortunately
it's dependent on exact stack layout, so I don't have anything simpler
than the situation described in
https://bugs.launchpad.net/ubuntu/+source/partman-base/+bug/527401/comments/23
which involved a sequence of foo="${foo#*, }" expansions on a long
string inside our RAID configuration tool.

The same fix has been in dash since 2007-09-26, contributed by Roy
Marples <uberlord@gentoo.org>.  I actually came up with it independently
almost to the character, but then synced it up with the variable naming
used in dash when I noticed that change afterwards.

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-26 14:21:27 +02:00
Denys Vlasenko
023a08f229 ash: line up builtin table. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-26 15:53:33 +01:00
Denys Vlasenko
496d5bf4c6 ash: trap with bad signal name should not abort
function                                             old     new   delta
trapcmd                                              236     271     +35

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-26 15:52:24 +01: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
b76356b28e ash: fix quadratic matching slowdown is ${v/*foo*/repl} (really bad one)
It is especially bad with patterns starting with "*".

With ASH_OPTIMIZE_FOR_SIZE=y, only those are optimized, +few bytes:
   text    data     bss     dec     hex filename
 836337     441    7564  844342   ce236 busybox_old
 836341     441    7564  844346   ce23a busybox_unstripped

With ASH_OPTIMIZE_FOR_SIZE off, we also optimize patterns _ending_ with "*",
which costs about 80 bytes:
   text    data     bss     dec     hex filename
 836656     441    7564  844661   ce375 busybox_old
 836732     441    7564  844737   ce3c1 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-13 16:19:04 +01:00
Denys Vlasenko
f15620c377 shell/ulimit: code shrink by 10 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-08 23:28:30 +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
4b1100edd8 *: use NULL for null pointers
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-05 14:10:54 +01:00
Denys Vlasenko
153fcaa6c1 Replace __uClinux__ define with !BB_MMU
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-02-21 05:17:41 +01:00
Denys Vlasenko
7426920461 fix bug 1087. Fix by Leonid (lly.dev AT gmail.com)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-02-21 01:26:42 +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
083e172641 style fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-28 12:30:24 +01:00
Denys Vlasenko
6b9f163353 *: style fixes. no code changes (verified with objdump)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-28 02:24:24 +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
85d286efc8 ash: remove config items for read options which are no longer optional
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-13 18:31:29 +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
03d81ef43a builtin_read: note about better implementation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-13 14:53:49 +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
045f4ad92c shell/read: fix "'read' without parameters" bash compat thingy
previous change:

function                                             old     new   delta
builtin_read                                          82    1074    +992
popstring                                            134     140      +6
readcmd                                             1034     148    -886
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 998/-886)          Total: 112 bytes

this change:

builtin_read                                        1074    1096     +22
static.arg_REPLY                                       8       -      -8
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 22/-8)              Total: 14 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 22:12:10 +01:00
Denys Vlasenko
7306727d1b shell: split read builtin from ash
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 22:11:24 +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
f2c8aa6676 libbb: introduce and use monotonic_ms
function                                             old     new   delta
monotonic_ms                                           -      60     +60
process_stdin                                        433     443     +10
display_speed                                         85      90      +5
nmeter_main                                          672     674      +2
builtin_type                                         114     116      +2
bb__parsespent                                       117     119      +2
ifplugd_main                                        1110    1109      -1
acpid_main                                           441     440      -1
chat_main                                           1361    1359      -2
doCommands                                          2458    2449      -9
arpping                                              466     450     -16
run_command                                          268     234     -34
readcmd                                             1072    1034     -38
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/7 up/down: 81/-101)           Total: -20 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 12:52:30 +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
8cd04d1cb6 ash: fix for read $IFS splitting. Closes bug 235
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-08 15:44:07 +01:00
Chris Metcalf
c3c1fb676b ash: fix mishandling of bash-style redirects
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-08 13:18:06 +01:00
Denys Vlasenko
2ec91aead5 *: remove some uses of argc
function                                             old     new   delta
whoami_main                                           34      37      +3
logname_main                                          60      63      +3
hostid_main                                           35      38      +3
ttysize_main                                         136     135      -1
nmeter_main                                          673     672      -1
logger_main                                          387     386      -1
uuencode_main                                        330     328      -2
ifupdown_main                                       2125    2123      -2
mesg_main                                            158     155      -3
free_main                                            333     330      -3
cal_main                                             902     899      -3
acpid_main                                           443     440      -3
ar_main                                              196     189      -7
find_main                                            476     467      -9
ifconfig_main                                       1235    1221     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/12 up/down: 9/-49)            Total: -40 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-04 14:15:38 +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
46a1477107 ash: trivial optimization -6 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-12-10 21:27:13 +01:00
Denys Vlasenko
e9ac32a067 ash: fix double comma in initializer
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-12-05 02:01:25 +01:00
Michael Abbott
359da5e3be ash: implement set -o pipefail (conditional on bash compat). +39 bytes
Signed-off-by: Michael Abbott <michael@araneidae.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-12-04 23:03:29 +01:00
Denys Vlasenko
285ad155c4 ash: preparatory work for pipefail and code shrink. -44 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-12-04 23:02:27 +01:00
Denys Vlasenko
7a7b034482 ash: re-enable SIGHUP on entry. Closes bug 771.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-12-04 04:18:31 +01:00
Denys Vlasenko
8eda4a9005 ash: straighten up a bit of code in varvalue()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-30 12:16:17 +01:00
Denys Vlasenko
2ce42e98d7 ash: more cosmetics and cleanups
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-29 02:18:13 +01:00
Denys Vlasenko
068d386a6c ash: cosmetics, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-29 01:41:11 +01:00
Denys Vlasenko
76bc2d6deb ash: remove last "signed char"; make SIT() clearer. -12 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-29 01:37:46 +01:00
Denys Vlasenko
0337e038a9 ash: randmconfig fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-29 00:12:30 +01:00
Denys Vlasenko
cd71683ae6 ash: remake strange signed char machinery to be unsigned. -57 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-28 22:14:02 +01:00
Denys Vlasenko
160b9ca731 ntpd: make it NOMMU-safe; ash: exclude it on NOMMU builds
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-27 02:35:15 +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
0d8c0b810e removed SuSv3 doc tarball - potential licensing problem
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-06 04:11:22 +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
f2cbb03a37 *: optimize most of isXXXXX() macros
text    data     bss     dec     hex filename
 824164     453    6812  831429   cafc5 busybox_old
 823730     453    6812  830995   cae13 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-23 03:16:08 +02: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
c0dab37d0a *: remove last function calls to isspace
function                                             old     new   delta
xstrtoul_range_sfx                                   232     231      -1
xstrtoull_range_sfx                                  295     293      -2
trim                                                  82      80      -2
trim_trailing_spaces_and_print                        57      52      -5
isspace                                               18       -     -18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-22 22:28:08 +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
36df04837a randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-19 16:07:28 +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
e7670ff81d ash: use bbox wrappers for malloc etc instead of homegrown ones
function                                             old     new   delta
popstring                                            134     140      +6
ckmalloc                                               9       -      -9
ckstrdup                                              22       -     -22
ckrealloc                                             24       -     -24
ckzalloc                                              28       -     -28
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 1/0 up/down: 6/-83)             Total: -77 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-11 00:45:25 +02:00
Denys Vlasenko
0e5e4eaf7b ash: trivial shrink by using smaller int
function                                             old     new   delta
copynode                                             197     196      -1
calcsize                                             127     126      -1
nodesize                                              54      27     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-29)             Total: -29 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-11 00:36:20 +02:00
Denys Vlasenko
e3c6e19015 laguage and copyright date corrections, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 23:35:30 +02:00
Denys Vlasenko
3dc4a3e4dc ash: make one testsuite entry more robust
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 23:08:28 +02:00
Denys Vlasenko
69d1f45c16 shell/Config.in: forgotten chunk with CONFIG_HUSH_RANDOM_SUPPORT
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 22:11:30 +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
3ea2e82dc7 ash: factor out $RANDOM support
function                                             old     new   delta
next_random                                            -      46     +46
ash_main                                            1361    1356      -5
change_random                                        132      97     -35
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 46/-40)              Total: 6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 20:59:04 +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
adf922ec28 *: a few more NOINLINEs
function                                             old     new   delta
print_linkinfo                                         -     815    +815
do_msg                                                 -     783    +783
INET_setroute                                          -     757    +757
varvalue                                               -     746    +746
do_sem                                                 -     637    +637
inflate_codes                                          -     617    +617
INET6_setroute                                         -     491    +491
edir                                                   -     370    +370
sync_cursor                                            -     298    +298
update_utmp                                            -     246    +246
searchLines                                            -     165    +165
setup_alarm                                            -     144    +144
may_wakeup                                             -     101    +101
getNum                                               566     371    -195
refresh                                             1166     848    -318
rtcwake_main                                         809     479    -330
getty_main                                          2396    1921    -475
chpst_main                                          1373     746    -627
inflate_unzip_internal                              1335     567    -768
evalvar                                             1384     612    -772
ipaddr_list_or_flush                                2160    1246    -914
route_main                                          1585     245   -1340
ipcs_main                                           2523    1049   -1474
------------------------------------------------------------------------------
(add/remove: 13/0 grow/shrink: 0/10 up/down: 6170/-7213)    Total: -1043 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-08 14:35:37 +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
57ce977a97 ash: compile breakage fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-08 04:19:14 +02:00
Denys Vlasenko
d427689eee Fix english in build system
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-06 22:13:37 +02:00
Denys Vlasenko
7bb346f23c *: use {i,u}toa() where appropriate
function                                             old     new   delta
startservice                                         377     363     -14
setari_u                                              54      40     -14
ash_main                                            1375    1361     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-42)             Total: -42 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-06 22:09:50 +02:00
Cristian Ionescu-Idbohrn
301f5ecb8d ash: error out on ${#1#}, ${#$11}, ${#11#}
Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-05 02:07:23 +02:00
Denys Vlasenko
4d8873f997 ash: document where we accept invalid syntax. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-04 03:14:41 +02:00
Denys Vlasenko
76622dbd16 ash: code shrink
function                                             old     new   delta
ulimitcmd                                            489     415     -74

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-04 01:14:19 +02:00
Denys Vlasenko
3a7034c27b typo fix in a comment in a testcase. oh well...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-30 02:48:59 +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
db9c57eed1 libbb/lineedit: fix the case when we configured history to have 0 lines
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-27 02:48:53 +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
8f88d85e34 ash: better comment. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-25 12:12:53 +02:00
Denys Vlasenko
726e1a04f7 ash: even smaller trap code
function                                             old     new   delta
evalvar                                             1371    1373      +2
trapcmd                                              347     260     -87

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-25 02:58:20 +02:00
Denys Vlasenko
e305c28285 ash: slightly better (more correct) code for "trap hack"
function                                             old     new   delta
changepath                                           194     195      +1
evalvar                                             1373    1371      -2
forkchild                                            602     590     -12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-25 02:12:27 +02:00
Denys Vlasenko
21d87d495a ash: better handling of EXIT trap in trap hack
function                                             old     new   delta
forkchild                                              -     602    +602
trapcmd                                              255     347     +92
ash_main                                            1362    1375     +13
evalvar                                             1371    1373      +2
popstring                                            140     134      -6
forkshell                                            835     248    -587
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/2 up/down: 709/-593)          Total: 116 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-25 00:06:51 +02:00
Denys Vlasenko
0800e3af75 ash: do not let EXIT trap to fire in trap
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-24 03:09:26 +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
1f27ab0d4b *: optimize code size in strtoul calls
function                                             old     new   delta
bb_parse_mode                                        433     431      -2
rtnl_rtntype_a2n                                     202     198      -4
ParseField                                           511     498     -13
bb_init_module_24                                   4730    4675     -55
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-74)             Total: -74 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-23 17:17:53 +02:00
Denys Vlasenko
844f990926 ash: fix trap
function                                             old     new   delta
forkshell                                            738     810     +72
popstring                                            134     140      +6
parse_command                                       1460    1463      +3
evalvar                                             1373    1371      -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 81/-2)              Total: 79 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-23 03:25:52 +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
1166d7b136 ash: fix bug 585 (>"$VAR_WITH_UNICODE_CHARS" problem)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-16 16:20:31 +02:00
Denys Vlasenko
b0d63383dd ash: preparatory cleanup. The only real changes are (unsigned char) casts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-16 16:18:32 +02:00
Denys Vlasenko
795633463a add a testcase for reopened bug 585 (not fixed yet)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-16 14:04:07 +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
043b1e5d99 more C standard compat fixes from Dan Fandrich
function                                             old     new   delta
docolon                                              207     204      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-06 12:47:55 +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
a00329ca8e ash: better comment. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-30 20:05:10 +02:00
Denys Vlasenko
7218af9f83 ash: revent one place where number() doesn't work
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-30 17:07:30 +02:00
Denys Vlasenko
ecc2a2e015 ash: deal with some TODOs (mostly trivial)
function                                             old     new   delta
msg_illnum                                             -      19     +19
evalvar                                             1365    1364      -1
illnum                                                19       -     -19
subevalvar                                          1182    1158     -24
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 19/-44)            Total: -25 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-29 22:53:41 +02:00
Denys Vlasenko
9f2e82ad2e ash: add testsuite for bug 585
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-29 20:37:09 +02:00
Denys Vlasenko
c8334a40c9 ash: fix handling of Unicode chars in redirects. Fixes bug 585
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-29 20:24:12 +02:00
Denys Vlasenko
b6c8434896 ash: trivial simplifications and optimizations
function                                             old     new   delta
rmescapes                                              -     256    +256
memtodest                                             94     103      +9
evalvar                                             1363    1365      +2
_rmescapes                                           256       -    -256
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/0 up/down: 267/-256)           Total: 11 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-29 20:23:20 +02:00
Denys Vlasenko
a12af2d9f3 ash: make "jobs -l" more similar to bash. By Earl Chew. Fixes bug 481
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-23 22:10:04 +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
ffc39202aa ash: fix bug 571 (jobs %string misbehaving)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-17 02:12:20 +02:00
Denys Vlasenko
dbfa45b3b2 hust test: complain if busybox binary can't be found
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-12 21:24:29 +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
09516066d4 hush: do not use ps -o in leak_argv1; do not hardcode path in negate
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-12 14:21:30 +02:00
Denys Vlasenko
7cee00e8ae ash: further fixes to debug machinery (closes bug 485)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-24 01:08:03 +02:00
Denys Vlasenko
e56f22ac60 ash: make "jobs" work even in subshells
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-24 00:16:59 +02:00
Denys Vlasenko
86e83ec487 ash: fix debug machinery a bit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-23 22:07:07 +02:00
Denys Vlasenko
252ccba948 remove msh_function.patch. msh is deprecated
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-19 01:09:42 +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
883cea4751 ash: fixes in debug printouts
Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-11 15:31:59 +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
641dd7b080 ash: revert over-zealous usage of FAST_FUNC
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-11 19:30:19 +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
2634bf366b randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-09 18:40:07 +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
71016baf55 printf: accept negative numbers for %x; sh: overflowed numbers are 0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-05 16:24:29 +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
eab40e5885 hush_test: stop mixing tabs/spaces for indentation
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 16:33:05 -04: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
Mike Frysinger
ff64fb9e31 hush_test: filter test output to avoid C lib differences
The getopt function in some C libraries wraps the option in single quotes
while others do not.  Avoid the issue by running sed on the output and
strip all quotes.

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
4f26c97b9a make compound.tests executable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-23 17:00:13 +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
342a63d659 hush_test: add some pathological compound list tests
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 18:35:37 -04:00
Mike Frysinger
12bcc76e9b hush_test: test for subshell function syntax
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 18:35:08 -04:00
Mike Frysinger
7b424fe738 hush_test: add subshelled case tests
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 18:09:24 -04:00
Mike Frysinger
cc9205bda7 hush_test: update test output to match new getopt() output
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 17:58:15 -04:00
Mike Frysinger
33f85eeac5 hush_test: ignore generated files
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 17:45:26 -04: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
Denys Vlasenko
318a8e5ed5 TODO: add some
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-13 02:18:43 +02: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
42e4af3119 make leak test more robust by unsetting all vars 2009-04-26 23:25:36 +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
d40fa397e4 hush: add two testcases 2009-04-20 10:52:31 +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
135cecbbce ash: fix warning in debug build 2009-04-12 00:00:57 +00:00
Denis Vlasenko
c43430f1b9 hush: remove functions from TODOs 2009-04-11 11:07:22 +00:00