Commit Graph

1876 Commits

Author SHA1 Message Date
Denys Vlasenko
f8ddbe1ccc ash: fix handling of ${VAR: -2}
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-25 03:56:00 +02:00
Denys Vlasenko
0fb0045aa9 config: disentangle PREFER_APPLETS from SH_STANDALONE and SH_NOFORK
On user request.
I thought enabling/disabling them all together is more consistent.
Evidently, some people do want them to be separately selectable.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-22 18:48:38 +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
e5814a5a42 ash: do not leave SIGQUIT ignored on "exec CMD"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-16 18:33:55 +02:00
Denys Vlasenko
3e134ebf6a *: slap on a few ALIGN1/2s where appropriate
The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map"

   text	   data	    bss	    dec	    hex	filename
 829901	   4086	   1904	 835891	  cc133	busybox_before
 829665	   4086	   1904	 835655	  cc047	busybox

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-22 18:09:21 +02:00
Ron Yorston
84ba50c32f ash: bash-compatible $'...' shouldn't expand in double quotes
Bash doesn't expand its $'...' construct in double quotes:

   $ echo "$'a\tb'"
   $'a\tb'

Change BusyBox ash to do the same.  This also fixes a problem with
here documents where BusyBox ash gave an incorrect result for:

   $ cat <<EOF
   > '$'
   > EOF
   '$'

Reported-by: Timo Teras <timo.teras@iki.fi>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-15 22:16:46 +02:00
Ron Yorston
2b91958dff Rewrite iteration through applet names to save a few bytes
function                                             old     new   delta
run_applet_and_exit                                  758     755      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3)               Total: -3 bytes

In standalone shell mode the saving increases to 17 bytes.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-15 22:13:51 +02:00
Mike Frysinger
b9b7aa1910 ash_test: ignore generated files
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-03-22 18:15:24 -04:00
Mike Frysinger
787972f60b ash_test: printenv: fix missing includes
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-03-22 18:15:14 -04:00
Ron Yorston
3e3bfb896e ash: fix corruption of ${#var} if $var contains UTF-8 characters
As reported in bug 8506:

   $ X=abcdÉfghÍjklmnÓpqrstÚvwcyz
   $ echo ${#X}
   abcd26

The result should be 26.

This regression was introduced by:

   <d68d1fb> 2015-05-18 [Ron Yorston]  ash: code shrink around varvalue

The length in characters was being used to discard the contents of
the variable instead of the length in bytes.

URL: https://bugs.busybox.net/8506
Reported-by: Martijn Dekker <martijn@inlv.org>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-03-22 18:19:29 -04:00
Kylie McClain
40eea690c7 Fix compiling with musl's utmp stubs
This patch fixes compiling busybox with FEATURE_UTMP and _WTMP enabled.
musl, while not really support utmp/wtmp, provides stub functions, as well
as variables such as _PATH_UTMP, so that programs using utmp or wtmp can
still compile fine.

My reasoning for this patch is that on Exherbo, I'm currently trying to get
us to be able to use the same busybox config file for both glibc and musl
systems, using utmp/wtmp on systems that support it, and using the stubs
on musl without needing two different configs.

As of latest musl git, it provides all utmp functions needed; 1.1.12 doesn't,
but I sent a patch to Rich to add the utmp{,x}name functions expected to
exist, which was merged into musl upstream.

Signed-off-by: Kylie McClain <somasissounds@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-02-01 01:36:05 +01:00
Cristian Ionescu-Idbohrn
c2a2625bcb ash: suppress a compilation warning
Reported by gcc (Debian 5.3.1-4) 5.3.1 20151219

shell/ash.c: In function 'evaltree':
shell/ash.c:8432:19: warning: logical not is only applied to the left hand side of comparison

Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-01-02 00:52:29 +01:00
Ron Yorston
95ebcf79ff ash: add support for bash 'function' keyword
Where the POSIX shell allows functions to be defined as:

   name () compound-command [ redirections ]

bash adds the alternative syntax:

   function name [()] compound-command [ redirections ]

Implement this in ash's bash compatibility mode.  Most compound
commands work (for/while/until/if/case/[[]]/{}); one exception is:

   function f (echo "no way!")

The other two variants work:

   f() (echo "ok")
   function f() (echo "also ok")

function                                             old     new   delta
parse_command                                       1555    1744    +189
tokname_array                                        232     240      +8
.rodata                                           155612  155566     -46
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 197/-46)           Total: 151 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-11-04 19:30:24 +01:00
Denys Vlasenko
bc9bee01f3 hush-misc/func_args1.tests: remove "UNFIXED BUG", it does not fail
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-11-04 14:50:19 +01:00
Ron Yorston
85405c80a2 ash: copy function tests from hush testsuite
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-11-04 14:48:16 +01:00
Ron Yorston
95650a86d1 ash: allow popredir to be called if the stack is empty
If /tmp/test.sh is a script that tries to run a second script which
happens to be non-executable this:

   command . /tmp/test.sh

causes a seg fault.

This is because clearredir is called in the error path to clear the
stack of redirections.  The normal path then calls popredir, but popredir
fails when the stack is empty.

Reported-by: Bastian Bittorf <bittorf@bluebottle.com>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-30 22:23:13 +01:00
Ron Yorston
8c55dc79a7 ash: fix EXEXEC status clobbering
evalcommand always clobbers the exit status in case of an EXEXEC
which means that exec always fails with exit status 2 regardless
of what it actually returns.

This patch adds the missing check for EXEXEC so that the correct
exit status is preserved.  It causes the test ash-misc/exec.tests
to succeed.

Based on commit 7f68426 in dash git, by Herbert Xu.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-30 22:19:48 +01:00
Ron Yorston
e939856c87 ash: add tests for failures of the exec and command builtins
The exec builtin should return an exit status of 127 if the command
can't be found.  It doesn't:  it returns 2.

If the command builtin is used to source a script that runs a second
script that doesn't exist ash should issue an error.  Instead it seg
faults.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-30 22:19:06 +01:00
Denys Vlasenko
112889d706 hush: copy for.tests from ash testsuite
This test passes for hush

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-29 22:37:25 +01:00
Ron Yorston
c0e007663d ash: simplify EOF/newline handling in list parser
Processing of here documents in ash has had a couple of breakages
which are now the subject of tests.  This commit should fix both.

It is based on the following commit in dash git by Herbert Xu:

   <7c245aa> [PARSER] Simplify EOF/newline handling in list parser

(See git://git.kernel.org/pub/scm/utils/dash/dash.git)

Reported-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-29 21:44:11 +01:00
Ron Yorston
6bd2fabc52 Revert "ash: fix a SEGV case in an invalid heredoc" xxx
This reverts commit 7e66102f76 but
leaves the test in place as it's still valid.

Reported-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-29 21:42:30 +01:00
Ron Yorston
713f07d906 ash: fix error during recursive processing of here document
Save the value of the checkkwd flag to prevent it being clobbered
during recursion.

Based on commit ec2c84d from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu.

function                                             old     new   delta
readtoken                                            190     203     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 13/0)               Total: 13 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-29 20:45:36 +01:00
Denys Vlasenko
7b14ede049 ash tests: make test print test name before it is run
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-29 20:34:20 +01:00
Ron Yorston
ef2386b80a ash: only allow local variables in functions
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-29 20:33:44 +01:00
Ron Yorston
3f221113a5 ash: respect -p flag when command builtin is run with -v/-V
The command builtin should only check the default path, not $PATH,
when the -p flag is used along with -v/-V.

Based on commits 65ae84b (by Harald van Dijk) and 29ee27d (by Herbert
Xu) from git://git.kernel.org/pub/scm/utils/dash/dash.git).

function                                             old     new   delta
commandcmd                                            72      87     +15
describe_command                                     437     450     +13
typecmd                                               84      86      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 30/0)               Total: 30 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-29 20:05:32 +01:00
Denys Vlasenko
e2f32c02b1 ash: fix command -- crash
busybox sh -c 'command --' segfaults because parse_command_args
returns a pointer to a null pointer.

Based on commit 18071c7 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Gerrit Pape.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-29 19:46:40 +01:00
Ron Yorston
383b885ff7 ash: save a few bytes in code to parse case statements
Based on commit 49b82fc from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu.

function                                             old     new   delta
parse_command                                       1563    1555      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-8)               Total: -8 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-29 19:36:08 +01:00
Ron Yorston
ab80e01cd9 ash: allow newline after variable name in for loop
Newline is a valid delimiter between the variable name and `in`
keyword in for loops.

Based on commit 22e8fb4 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu.

function                                             old     new   delta
parse_command                                       1568    1563      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5)               Total: -5 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-29 19:30:55 +01:00
Ron Yorston
9121510dc6 ash: add test for issue with here document
This used to work but doesn't now:

foo () {
cat <<EOF && { echo "$1" ; }
$1
EOF
}

foo "bar"

Reported-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-29 19:12:03 +01:00
Denys Vlasenko
00da72bee0 tidy up strtok use
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-23 18:43:16 +02:00
Denys Vlasenko
450a367a11 typo fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-13 01:49:06 +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
005c492c40 ash: shrink umask code
function                                             old     new   delta
umaskcmd                                             258     248     -10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-10 20:17:12 +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
4cd99e7c6c ash: "you have mail" should ignore first change in mtime
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-09 16:02:53 +02:00
Denys Vlasenko
2384162f64 ash: simplify "you have mail" code
function                                             old     new   delta
mailtime_hash                                          -       4      +4
redirect                                            1282    1280      -2
mailtime                                              40       -     -40
cmdloop                                              429     378     -51
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 4/-93)             Total: -89 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-09 15:52:03 +02:00
Denys Vlasenko
4700fb5bea ash: make dowait() a bit more readable. Logic is unchanged
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-09 15:40:13 +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
ec046f74a3 ash: use a more typical form of "print four octal digits" format
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-07 17:57:53 +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
c1e2e005b4 ash: shrink "umask -S" code
function                                             old     new   delta
umaskcmd                                             279     286      +7
static.permmode                                        3       -      -3
static.permmask                                       18       -     -18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-07 17:32:56 +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
9c5410023a ash: a bunch of trivial simplifications
Also, in a few places made code more reliable wrt large sizeof(int)
and sizeof(arith_t)..

function                                             old     new   delta
sprint_status48                                        -     143    +143
newline_and_flush                                      -      56     +56
showjob                                              365     382     +17
parse_command                                       1440    1443      +3
cmdputs                                              334     332      -2
cmdloop                                              434     429      -5
showjobs                                              70      64      -6
fg_bgcmd                                             296     290      -6
ash_vmsg                                             159     153      -6
ash_main                                            1487    1481      -6
jobscmd                                               94      82     -12
getoptscmd                                           687     632     -55
outcslow                                              56       -     -56
sprint_status                                        156       -    -156
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 2/8 up/down: 219/-310)          Total: -91 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-07 15:44:36 +02:00
Ron Yorston
ca25af9b06 ash: fix slash treatment in expmeta
Commit 549deab caused this sequence of commands:

   mkdir foo
   cd foo
   touch a b
   echo "./"*

to return './*' instead of the expected './a ./b'.  The problem
was caused by the backport of commit 880d952 from dash.  In dash
the issue was fixed by two further commits by Herbert Xu:

<d6d06ff> [EXPAND] Fixed non-leading slash treatment in expmeta
<36f0fa8> [EXPAND] Fix slash treatment in expmeta

(See git://git.kernel.org/pub/scm/utils/dash/dash.git)

Apply these fixes to BusyBox ash, thus causing the new test
glob3.tests to succeed.

function                                             old     new   delta
expmeta                                              469     528     +59

Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-09-04 22:23:54 +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
Denys Vlasenko
26c423d9a8 ash,hush: add a test which fails for ash since commit 549deab
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-09-04 03:33:02 +02:00
Denys Vlasenko
66a781acb9 ash: add tests adapted from hush glob tests. glob2.tests currently fails
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-09-04 03:27:08 +02:00
Ron Yorston
d840c5d139 libbb: add a function to make a copy of a region of memory
Introduce a library routine to package the idiom:

    p = xmalloc(b, n);
    memcpy(p, b, n);

and use it where possible.  The example in traceroute used xzalloc
but it didn't need to.

function                                             old     new   delta
xmemdup                                                -      32     +32
last_main                                            834     826      -8
make_device                                         2321    2311     -10
common_traceroute_main                              3698    3685     -13
readtoken1                                          3182    3168     -14
procps_scan                                         1222    1206     -16
forkchild                                            655     638     -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/6 up/down: 32/-78)            Total: -46 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-19 23:05:20 +02:00
Ron Yorston
072fc60f29 ash: use alloca to get rid of setjmp
Now that the only thing protected by setjmp/longjmp is the saved string,
we can allocate it on the stack to get rid of the jump.

Based on commit bd35d8e from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu.

function                                             old     new   delta
readtoken1                                          3182    3116     -66
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-66)             Total: -66 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-13 04:02:45 +02:00
Denys Vlasenko
f54a487bb4 fix file mode
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-13 03:52:32 +02:00
Ron Yorston
0e056f7e9e ash: remove parsebackquote flag
Commit 503a0b8 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu says:

  >The parsebackquote flag is only used in a test where it always has the
  >value zero.  So we can remove it altogether.

The first statement is incorrect:  parsebackquote is non-zero when
backquotes (as opposed to $(...)) are used for command substitution.
It is possible for the test to be executed with parsebackquote != 0 in
that case.

The test is question checks whether quotes have been closed, raising
the error "unterminated quoted string" if they haven't.  There seems
to be no good reason to allow unclosed quotes within backquotes.  Bash,
hush and dash (after commit 503a0b8) all treat the following as an error:

   XX=`"pwd`

whereas BusyBox ash doesn't.  It just ignores the unclosed quote and
executes pwd.

So, parsebackquote should be removed but not for the reason stated.

function                                             old     new   delta
parsebackquote                                         1       -      -1
readtoken1                                          3222    3182     -40
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-41)             Total: -41 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-13 03:50:27 +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
9a595bb36d hush: add recent ash tests to hush testsuite too (they all pass for hush)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-18 10:23:16 +02:00
Ron Yorston
523006798c testsuite: add some tests for ash
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-18 10:13:21 +02:00
Ron Yorston
417622cc2e ash: fix breakage of ${v/pat/str}
The commit

   ash: move parse-time quote flag detection to run-time

breaks pattern substitution in parameter expansion.  Fix this and
revise the code so that the different handling of the pattern and
the replacement string takes place in rmescapes rather than the
separate function parse_sub_pattern.

function                                             old     new   delta
rmescapes                                            227     273     +46
static.qchars                                          3       4      +1
subevalvar                                          1177    1157     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 47/-20)             Total: 27 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-18 09:59:14 +02:00
Ron Yorston
549deab5ab ash: move parse-time quote flag detection to run-time
Because the parser does not recursively parse parameter expansion
with respect to quotes, we can't accurately determine quote status at
parse time.  This patch works around this by moving the quote detection
to run-time where we do interpret it recursively.

Test case:
   foo=\\ echo "<${foo#[\\]}>"
Old result:
   <\>
New result:
   <>

Do not quote back slashes in parameter expansions outside quotes.

Test case:
   a=/b/c/*
   b=\\
   echo ${a%$b*}
Old result:
   /b/c/*
New result:
   /b/c/

Based on commits 880d952, 7cfd8be, 0d7d660 and a7c21a6 from
git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu

function                                             old     new   delta
argstr                                              1164    1193     +29
memtodest                                            147     174     +27
subevalvar                                          1153    1177     +24
redirect                                            1279    1282      +3
dolatstr                                               5       7      +2
static.spclchars                                      10       9      -1
expandarg                                            962     960      -2
evalcase                                             273     271      -2
evalcommand                                         1204    1197      -7
rmescapes                                            236     227      -9
preglob                                               27       8     -19
evalvar                                              604     582     -22
cmdputs                                              389     334     -55
readtoken1                                          3163    3061    -102
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/9 up/down: 85/-219)          Total: -134 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-18 09:57:51 +02:00
Ron Yorston
ad88bdee0c ash: remove arithmetic expansion collapsing at parse time
Collapsing arithmetic expansion is incorrect when the inner arithmetic
expansion is a part of a parameter expansion.

Test case:
   unset a
   echo $((3 + ${a:=$((4 + 5))}))
   echo $a
Old result:
   12
   (4 + 5)
New result:
   12
   9

Based on commit bb777a6 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu

function                                             old     new   delta
readtoken1                                          3180    3163     -17

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-18 09:56:16 +02:00
Ron Yorston
7e4ed267b6 ash: remove superfluous code in arithmetic mode
Based on commits 1a74845, cfc3d6a and ff13779 from
git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu

function                                             old     new   delta
evalcommand                                         1197    1204      +7
localcmd                                             327     325      -2
readtoken1                                          3200    3180     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 7/-22)             Total: -15 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-18 09:54:43 +02:00
Ron Yorston
3df47f9cbb ash: do not expand tilde in parameter expansion within quotes
Test case:
   unset a
   echo "${a:-~root}"
Old result:
   /root
New result:
   ~root

Based on commit 170f44d from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu

function                                             old     new   delta
evalvar                                              598     604      +6
parse_command                                       1440    1443      +3
localcmd                                             325     327      +2
readtoken1                                          3199    3200      +1
argstr                                              1180    1164     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 12/-16)             Total: -4 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-18 09:53:26 +02:00
Ron Yorston
eb6b48ba74 ash: perform tilde expansion in all parameter expansion words
Previously tilde expansion was not carried out for =?#% expansion words.

Test case:
   a=~root:~root
   echo ${a#~root}
Old result:
   /root:/root
New result:
   :/root

Based on commit dd721f71 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu

function                                             old     new   delta
subevalvar                                          1152    1153      +1

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-18 09:51:35 +02:00
Ron Yorston
d68d1fbd6c ash: code shrink around varvalue
Based on commit c989d72 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu

function                                             old     new   delta
strtodest                                              -      40     +40
memtodest                                            123     147     +24
parse_command                                       1443    1440      -3
readtoken1                                          3205    3199      -6
argstr                                              1203    1180     -23
varvalue                                             788     660    -128
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/4 up/down: 64/-160)           Total: -96 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-18 09:49:28 +02:00
Denys Vlasenko
e0a4e107aa ash: explain what "local -" does
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-13 02:20:14 +02:00
Eugene Rudoy
1285aa62f9 ash: consider "local -" case while iterating over local variables in mklocal.
fixes segfault introduced in 0a0acb55db with functions using "local -".
test-case: f() { local -; local x; }; f

note: with this change applied multiple 'local -'s still cause multiple entries to be added to the localvars list.
this problem will be addressed in a separate commit.

Signed-off-by: Eugene Rudoy <gene.devel@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-13 02:09:53 +02:00
Ron Yorston
61d6ae244a libbb: remove unnecessary argument to nonblock_immune_read
The loop_on_EINTR argument to nonblock_immune_read is always set to 1.

function                                             old     new   delta
xmalloc_reads                                        200     195      -5
pgetc                                                488     483      -5
argstr                                              1313    1308      -5
nonblock_immune_read                                 123      86     -37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-52)             Total: -52 bytes

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-20 13:41:32 +02:00
Denys Vlasenko
73327a048b hush: document buggy handling of duplicate "local"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-18 19:38:13 +02:00
Denys Vlasenko
0a0acb55db ash: fix handling of duplicate "local"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-18 19:36:38 +02:00
Ron Yorston
75a76269ba ash: do not split the result of tilde expansion
A tilde expansion generates a valid pathname. Splitting it using IFS
either leaves it unchanged or changes it to something unintended.

Example:
   IFS=m HOME=/tmp; printf "%s\n" ~

Based on this commit authored by Jilles Tjoelker:

   http://git.kernel.org/cgit/utils/dash/dash.git/commit/?id=834629283f6c629a4da05ef60bae9445c954a19a

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-22 16:55:44 +01: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
7e66102f76 ash: fix a SEGV case in an invalid heredoc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-05 21:00:17 +01:00
Denys Vlasenko
c76236fd7d ash: fix a SEGV in ${#1}
function                                             old     new   delta
varvalue                                             760     805     +45
evalvar                                              648     603     -45

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-29 00:04:18 +01:00
Denys Vlasenko
f5add44981 typo fix in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-20 01:43:30 +01:00
Denys Vlasenko
8a475def9e ash,hush: do not segfault on $((2**63 / -1))
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-18 14:32:58 +01:00
Denys Vlasenko
08a5dab181 ash: fix handling of negative start value in ${v:start:len}
function                                             old     new   delta
subevalvar                                          1140    1168     +28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-17 20:27:18 +01:00
Denys Vlasenko
07f7ea70ed ash: fix off-by-one in "jobs %4" handling. closes 7310
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-08 17:21:52 +02:00
Denys Vlasenko
2ec34969e7 ash: factor out ASH_HELP config option
It used to be aliased to !FEATURE_SH_EXTRA_QUIET for ash,
while hush had it separate from FEATURE_SH_EXTRA_QUIET.

Bring ash in line with hush.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-08 16:52:39 +02:00
Denys Vlasenko
e9ab07c211 ash: make ${#var} unicode-aware
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-08-13 18:00:08 +02: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
Bartosz Golaszewski
5d2e409ef8 libbb: use a wrapper around sysconf(_SC_CLK_TCK) to save a few bytes
function                                             old     new   delta
bb_sc_clk_tck                                          -      10     +10
timescmd                                             118     113      -5
print_route                                         1763    1758      -5
mpstat_main                                         1288    1283      -5
iostat_main                                         1947    1942      -5
INET_setroute                                        879     871      -8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/5 up/down: 10/-28)            Total: -18 bytes
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-22 14:01:13 +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
109ee5d336 ash: make "locak VAR" unset VAR (bash does that)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-03-16 18:41:11 +01:00
Denys Vlasenko
ac03a40cba ash,hush: fix a thinko about 2^64-1 factorization
function                                             old     new   delta
next_random                                          113     119      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-03-15 09:25:46 +01: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
f93187512d random: cosmetic tweaks in debug code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-03-13 13:03:27 +01:00
Denys Vlasenko
fb183076a3 ash,hush: improve randomness of $RANDOM, add easy-ish way to test it
function                                             old     new   delta
next_random                                           68     113     +45
change_random                                        103     121     +18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-03-13 12:52:43 +01:00
Denys Vlasenko
5680e98451 ash: in bash compat mode, always export $SHLVL
function                                             old     new   delta
ash_main                                            1437    1442      +5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-07 16:12:48 +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
Bernhard Reutner-Fischer
80f8cdf04a ash: Set SHLVL in ASH_BASH_COMPAT
function                                             old     new   delta
ash_main                                            1456    1505     +49
.rodata                                           148488  148494      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 55/0)               Total: 55 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-11-08 14:30:20 +01:00
Bernhard Reutner-Fischer
200c1c46f4 ash: Use setvar2 some more
(add/remove: 0/0 grow/shrink: 10/15 up/down: 13/-27)          Total: -14 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-11-08 14:12:13 +01:00
Denys Vlasenko
25ce3ee9f3 typo fix in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-14 01:23:06 +02: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
091f831424 ash: add comment about failures in source builtin. No code changes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-17 14:25:22 +01: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
Stefan Hellermann
4ef1439c59 ash: read $HOME/.profile instead of $(pwd)/.profile
ash --login should read ~/.profile instead of .profile in the current
directory. I noticed it while trying to figure out why /root/.profile
is only read sometimes.

function                                             old     new   delta
ash_main                                            1374    1398     +24

Signed-off-by: Stefan Hellermann <stefan@the2masters.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-15 02:45:50 +01:00
Stefan Hellermann
aeb717aa5e ash: move code to allow setting $HOME in /etc/profile
move HISTFILE=$HOME/.ash_history below reading /etc/profile,
so that /etc/profile can set $HOME. HOME can be unset when
directly invoking ash --login from init without going through
getty.

Signed-off-by: Stefan Hellermann <stefan@the2masters.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-15 02:37:51 +01:00
Denys Vlasenko
1961aea305 move endofname() to libbb
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-26 00:36:53 +01:00
Denys Vlasenko
7c4b13e019 ash: revert wrong "fix" for an apparent memory leak. Closes 5822
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-17 13:02:27 +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
Jon Tollefson
4ba6c5d3ba ash: fix a memory leak
The script which triggers the leak:

while true
  do
    while true
      do
        break;
    done</dev/null
done

Signed-off-by: Jon Tollefson <kniht@linux.vnet.ibm.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-11-13 19:26:53 +01:00
Denys Vlasenko
d527588882 ash: implement export -n
function                                             old     new   delta
exportcmd                                            129     175     +46

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-01 13:41:17 +02:00
Denys Vlasenko
0b4980c252 ash: trivial fixes for compile failures
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-25 12:49:29 +02:00
Denys Vlasenko
9e71e3cea5 ash: fix "read -s" + ^C. Closes 5504
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-06 13:28:10 +02:00
Michael Tokarev
32f774cd34 *: declare strings with ALIGN1, as appropriate
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-24 15:56:37 +02:00
Denys Vlasenko
566a313a7f ash: add a comment about VEXPORT
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-07 21:40:35 +02:00
Mike Frysinger
c5fe9f7b72 include sys/resource.h where needed
We use functions from sys/resource.h in misc applets, but don't include
the header.  This breaks building with newer glibc versions, so add the
include where needed.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-07-05 23:19:09 -04:00
Denys Vlasenko
f451b2cfe0 ash: fix a bug in >${varexp} handling. Closes 5282
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-09 02:06:57 +02: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
Aaro Koskinen
6e9d047c15 cttyhack: handle multiple consoles found in sysfs
If multiple consoles are found from the sysfs file, cttyhack fails:

cttyhack: can't open '/dev/tty0 ttyS0': No such file or directory

In such cases take the last one as the kernel will use that one for
/dev/console.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-02-04 21:55:01 +01:00
Denys Vlasenko
7ce209b9d4 shell_builtin_read: set cc[VMIN] to 1; lineedit: don't clear c_cc[VINTR]
First change fixes "read -n NUM". Apparently poll() won't report
data availability if cc[VMIN] > 1 until there are at least cc[VMIN] bytes.

function                                             old     new   delta
read_line_input                                     3885    3877      -8
shell_builtin_read                                  1097    1087     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18)             Total: -18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-15 22:58:06 +01:00
Denys Vlasenko
83f103b30e ash: in standalone mode, search in $PATH if /proc/self/exe doesn't exist
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-12-20 06:10:35 +01:00
Denys Vlasenko
cda6ea905d ash: document bash's exit code too. No code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-12-16 00:44:36 +01:00
Denys Vlasenko
2bef526331 ash: add comment about bash's ENOEXEC handling. No code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-12-16 00:25:17 +01:00
Denys Vlasenko
f8a5b792ba cttyhack: move /sys/class/tty/console/active check to the front
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-31 16:57:04 +01:00
Alexander Shishkin
156840c249 cttyhack: print detected ctty name when called without parameters
Sometimes there's a need to figure out the controlling tty from a shell
script, for example, to obtain a line for getty. In this case it's easier
to call cttyhack than trying to repeat some of the cttyhack's logic.

function                                             old     new   delta
cttyhack_main                                        283     327     +44
packed_usage                                       28911   28915      +4

Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-31 13:18:44 +01: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
Kevin Cernekee
4619802a5f cttyhack: trivial spelling/spacing fixes
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-16 23:31:03 +02:00
Kevin Cernekee
816cd16a4c cttyhack: remove the trailing newline when reading console name from sysfs
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-16 23:29:54 +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
Kevin Cernekee
43a668b2ee cttyhack: fail gracefully if the device node is missing
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-13 09:30:36 +02:00
Kevin Cernekee
064e99646a cttyhack: check sysfs for the name of the active console
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-13 09:26:58 +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
bcf1fa80f3 hush: add tests for interrupting read
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-09 01:05:33 +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
80c5b6893d libbb: nonblock_safe_read->nonblock_immune_read, remove unused param of xmalloc_reads
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-08 21:21:10 +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
Ian Wienand
89b3cbaa97 ash: clear sa_flags always
Signed-off-by: Ian Wienand <ianw@vmware.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-16 20:05:14 +02:00
Denys Vlasenko
e32d05b708 ash,hush: add ulimit -e -r (RLIMIT_NICE, RLIMIT_RTPRIO)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-04 02:12:14 +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
c162bcdcd1 hush: document a bug about aborting on sourced file error when non-interactive
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-24 05:38:51 +01: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
976ec23da5 remove stray empty line
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-07 13:12:01 +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
aefe1c260e ash: fix execution of shell scripts without shebang
We were assuming #!/bin/sh, whereas we had to simply re-enter ash.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-07 12:02:40 +01:00
Denys Vlasenko
940c7206c2 convert "do {...} while (1);" -> "while (1) {...}"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-02 04:07:14 +01:00
Denys Vlasenko
bac0a25f72 slightly better wording in comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-21 03:47:50 +01:00
Denys Vlasenko
b12553faa8 ash: fix ash-signals/signal8 testcase failure
function                                             old     new   delta
killcmd                                              109     224    +115
kill_main                                            882     910     +28
changepath                                           194     195      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 144/0)             Total: 144 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-21 03:22:20 +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
046341e8bd ash: optional support for $TMOUT variable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-04 17:53:59 +01:00
Denys Vlasenko
8c52f80397 ash: cosmetic cleanups
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-04 17:36:21 +01:00
Denys Vlasenko
b7c9fb27cb whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-03 00:05:48 +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
8d0e0cdadf move utmp.h include to libbb.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-25 23:21:46 +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
6088e138e1 init: simpler handling of leading dash in commands
function                                             old     new   delta
init_exec                                            233     219     -14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-12-25 23:58:42 +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
fb132e4737 whitespace cleanup
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-10-29 11:46:52 +02: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
cacb2cd281 *: whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-05 00:13:02 +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
2bcba5cc53 hush: add brace expansion testcase
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-03 17:07:57 +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
b563f62bbb ash: fix signal and "set -e" interaction
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-09-25 17:15:13 +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
395b97aeac shell/math: better comment. no code changes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-17 18:02:17 +02:00