oweals/busybox.git
7 years agohush: fix ${##}, ${#?}, ${#!} handling
Denys Vlasenko [Tue, 25 Jul 2017 22:07:27 +0000 (00:07 +0200)]
hush: fix ${##}, ${#?}, ${#!} handling

function                                             old     new   delta
parse_dollar                                         786     820     +34
expand_one_var                                      1579    1592     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 47/0)               Total: 47 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: [SHELL] Optimize dash -c "command" to avoid a fork
Denys Vlasenko [Tue, 25 Jul 2017 18:31:14 +0000 (20:31 +0200)]
ash: [SHELL] Optimize dash -c "command" to avoid a fork

Upstream commit:

    Date: Thu, 7 Jul 2011 13:58:48 +0800
    [SHELL] Optimize dash -c "command" to avoid a fork

    On Sun, Apr 10, 2011 at 07:36:49AM +0000, Jonathan Nieder wrote:
    > From: Jilles Tjoelker <jilles@stack.nl>
    > Date: Sat, 13 Jun 2009 16:17:45 -0500
    >
    > This change only affects strings passed to -c, when the -s option is
    > not used.
    >
    > Use the EV_EXIT flag to inform the eval machinery that the string
    > being passed is the entirety of input.  This way, a fork may be
    > omitted in many special cases.
    >
    > If there are empty lines after the last command, the evalcmd will not
    > see the end early enough and forks will not be omitted. The same thing
    > seems to happen in bash.
    >
    > Example:
    >   sh -c 'ps lT'
    > No longer shows a shell process waiting for ps to finish.
    >
    > [jn: ported from FreeBSD SVN r194128.  Bugs are mine.]
    >
    > Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>

    Instead of detecting EOF using the input layer, I'm going to
    use the parser instead.  In either case, we always have to read
    ahead in order to complete the parsing of the previous node.
    Therefore we always know whether there is more to come, except
    in the case where we see a newline/semicolon or similar.

    For the purposes of sh -c, this should be sufficient.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
function                                             old     new   delta
evalstring                                           190     224     +34
ash_main                                            1014    1022      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 42/0)               Total: 42 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: allow "trap NUM [SIG]..." syntax
Denys Vlasenko [Tue, 25 Jul 2017 18:06:17 +0000 (20:06 +0200)]
ash: allow "trap NUM [SIG]..." syntax

While at it, make get_signum() return -1 for numeric strings >= NSIG.

function                                             old     new   delta
trapcmd                                              292     306     +14
get_signum                                           295     300      +5
builtin_trap                                         413     412      -1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 19/-1)              Total: 18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: [REDIR] Replace GPL noclobberopen code with the FreeBSD version
Denys Vlasenko [Tue, 25 Jul 2017 15:47:48 +0000 (17:47 +0200)]
ash: [REDIR] Replace GPL noclobberopen code with the FreeBSD version

Upstream commit:

    Date: Thu, 10 Mar 2011 16:52:13 +0800
    [REDIR] Replace GPL noclobberopen code with the FreeBSD version

    Replace noclobberopen() from bash with the FreeBSD code for noclobber
    opens.

    This also reduces code size by eliminating an unnecessary check.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
function                                             old     new   delta
changepath                                           192     194      +2
localcmd                                             366     364      -2
expmeta                                              521     517      -4
redirect                                            1210    1135     -75
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 2/-81)             Total: -79 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: sync up with dash with respect to redirection escaping
Denys Vlasenko [Tue, 25 Jul 2017 15:37:57 +0000 (17:37 +0200)]
ash: sync up with dash with respect to redirection escaping

We fixed the problem differently than they. Let's not deviate.

Upstream commit:

    Date: Thu, 27 May 2010 20:07:29 +1000
    [EXPAND] Fix corruption of redirections with byte 0x81

    In other ash variants, a partial implementation of ksh-like cmd >file*
    adds and removes CTLESC bytes ('\x81') in redirection filenames,
    preserving 8-bit transparency. Long ago, dash removed the code to add
    the CTLESC bytes, but not the code to remove them, causing corruption of
    filenames containing CTLESC. This commit removes the code to remove the
    CTLESC bytes.

    The CTLESC byte occurs frequently in UTF-8 encoded non-Latin text.

    This bug has been reported various times to Ubuntu and Debian (e.g.
    Launchpad Ubuntu #422298). This patch is the same as the one submitted
    by Alexander Korolkov in Ubuntu #422298.

Signed-off-by: Jilles Tjoelker <jilles@stack.nl>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
function                                             old     new   delta
changepath                                           194     192      -2
expandarg                                           1000     984     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18)             Total: -18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: [VAR] Move unsetvar functionality into setvareq
Denys Vlasenko [Tue, 25 Jul 2017 14:29:36 +0000 (16:29 +0200)]
ash: [VAR] Move unsetvar functionality into setvareq

Upstream commit:

    Date: Tue, 25 May 2010 20:55:05 +0800
    [VAR] Move unsetvar functionality into setvareq

    This patch moves the unsetvar code into setvareq so that we can
    no have a pathological case of an unset variable hanging around
    unless it has a bit pinning it like VEXPORT.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
function                                             old     new   delta
setvareq                                             227     303     +76
expmeta                                              517     521      +4
localcmd                                             364     366      +2
unsetcmd                                              96      76     -20
unsetvar                                             129       7    -122
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 82/-142)           Total: -60 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: import param_expand_default.tests from hush
Denys Vlasenko [Tue, 25 Jul 2017 13:25:07 +0000 (15:25 +0200)]
ash: import param_expand_default.tests from hush

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: treat ${#?} as "length of $?"
Denys Vlasenko [Tue, 25 Jul 2017 13:18:57 +0000 (15:18 +0200)]
hush: treat ${#?} as "length of $?"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: add a few tests from hush-vars/*
Denys Vlasenko [Tue, 25 Jul 2017 12:55:05 +0000 (14:55 +0200)]
ash: add a few tests from hush-vars/*

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agovolume_id: enable minix detection
Denys Vlasenko [Tue, 25 Jul 2017 12:22:08 +0000 (14:22 +0200)]
volume_id: enable minix detection

function                                             old     new   delta
volume_id_probe_minix                                  -      87     +87
fs2                                                   64      68      +4
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/0 up/down: 91/0)               Total: 91 bytes

Patch by wdlkmpx <wdlkmpx@gmail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: fix comment, no code changes
Denys Vlasenko [Mon, 24 Jul 2017 18:03:24 +0000 (20:03 +0200)]
ash: fix comment, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: copy three tests from hush_test/hush-signals/*
Denys Vlasenko [Mon, 24 Jul 2017 17:42:46 +0000 (19:42 +0200)]
ash: copy three tests from hush_test/hush-signals/*

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoshell: some additions to *sh-misc/* tests
Denys Vlasenko [Mon, 24 Jul 2017 16:51:40 +0000 (18:51 +0200)]
shell: some additions to *sh-misc/* tests

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotar: postpone creation of symlinks with "suspicious" targets. Closes 8411
Denys Vlasenko [Mon, 24 Jul 2017 15:20:13 +0000 (17:20 +0200)]
tar: postpone creation of symlinks with "suspicious" targets. Closes 8411

function                                             old     new   delta
data_extract_all                                     968    1038     +70
tar_main                                             952     986     +34
scan_tree                                            258     262      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 108/0)             Total: 108 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoudhcpc: downgrade "MAC X:X:X:X:X:X" message to log2 level
Denys Vlasenko [Mon, 24 Jul 2017 11:37:38 +0000 (13:37 +0200)]
udhcpc: downgrade "MAC X:X:X:X:X:X" message to log2 level

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: add most of hush process subst tests
Denys Vlasenko [Mon, 24 Jul 2017 10:49:49 +0000 (12:49 +0200)]
ash: add most of hush process subst tests

ash passes these.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: fix a case when redirect to a closed fd #1 is not restoring (closing) it
Denys Vlasenko [Mon, 24 Jul 2017 10:42:17 +0000 (12:42 +0200)]
hush: fix a case when redirect to a closed fd #1 is not restoring (closing) it

function                                             old     new   delta
setup_redirects                                      200     245     +45
append_squirrel                                        -      41     +41
save_fds_on_redirect                                 256     221     -35
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 86/-35)             Total: 51 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoudhcpc[6]: downgrade "adapter index N" messages to log2 level
Denys Vlasenko [Mon, 24 Jul 2017 10:06:53 +0000 (12:06 +0200)]
udhcpc[6]: downgrade "adapter index N" messages to log2 level

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoudhcpc[6]: fix messages referring to select() while we use poll()
Denys Vlasenko [Mon, 24 Jul 2017 10:01:28 +0000 (12:01 +0200)]
udhcpc[6]: fix messages referring to select() while we use poll()

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: add all hush parsing tests to ast tests
Denys Vlasenko [Mon, 24 Jul 2017 00:49:56 +0000 (02:49 +0200)]
ash: add all hush parsing tests to ast tests

All pass.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: use mempcpy where useful
Denys Vlasenko [Mon, 24 Jul 2017 00:17:05 +0000 (02:17 +0200)]
hush: use mempcpy where useful

function                                             old     new   delta
o_addblock                                            58      42     -16
expand_one_var                                      1618    1555     -63
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-79)             Total: -79 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: fix for last commit
Denys Vlasenko [Sun, 23 Jul 2017 19:55:40 +0000 (21:55 +0200)]
ash: fix for last commit

"mempcpy(q, s, len) + len" is obviously no good :(

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: use mempcpy() in more places
Denys Vlasenko [Sun, 23 Jul 2017 19:46:02 +0000 (21:46 +0200)]
ash: use mempcpy() in more places

Most changes are taken from dash.

function                                             old     new   delta
single_quote                                         127     129      +2
stack_nputstr                                         28      29      +1
path_advance                                         209     202      -7
rmescapes                                            346     308     -38
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 3/-45)             Total: -42 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agozcip: fix slow environment leak
Denys Vlasenko [Sat, 22 Jul 2017 01:04:20 +0000 (03:04 +0200)]
zcip: fix slow environment leak

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agocrond: do not assume setenv() does not leak
Denys Vlasenko [Sat, 22 Jul 2017 00:25:47 +0000 (02:25 +0200)]
crond: do not assume setenv() does not leak

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agolibbb: avoid malloc/free in bb_unsetenv()
Denys Vlasenko [Sat, 22 Jul 2017 00:15:17 +0000 (02:15 +0200)]
libbb: avoid malloc/free in bb_unsetenv()

function                                             old     new   delta
bb_unsetenv                                           55      83     +28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agocrond: allow $SHELL and starting user's shell override DEFAULT_SHELL. Closes 6458
Denys Vlasenko [Fri, 21 Jul 2017 23:47:19 +0000 (01:47 +0200)]
crond: allow $SHELL and starting user's shell override DEFAULT_SHELL. Closes 6458

function                                             old     new   delta
crond_main                                          1134    1149     +15
fork_job                                             453     454      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: use mempcpy() where appropriate
Denys Vlasenko [Fri, 21 Jul 2017 16:51:29 +0000 (18:51 +0200)]
ash: use mempcpy() where appropriate

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agobasename: do not use argc
Denys Vlasenko [Fri, 21 Jul 2017 16:41:46 +0000 (18:41 +0200)]
basename: do not use argc

function                                             old     new   delta
basename_main                                        153     148      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agopgrep: fix "pgrep -v -P1"; also allow matching of comm - closes 10086
Denys Vlasenko [Fri, 21 Jul 2017 15:43:14 +0000 (17:43 +0200)]
pgrep: fix "pgrep -v -P1"; also allow matching of comm - closes 10086

function                                             old     new   delta
pgrep_main                                           662     720     +58

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoping: fix help text to show what parameter -p takes
Denys Vlasenko [Fri, 21 Jul 2017 14:07:13 +0000 (16:07 +0200)]
ping: fix help text to show what parameter -p takes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: suppress readonly1.tests false positive; add readonly0.tests
Denys Vlasenko [Fri, 21 Jul 2017 11:37:25 +0000 (13:37 +0200)]
ash: suppress readonly1.tests false positive; add readonly0.tests

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: improve set -x to quote strings as necessary
Denys Vlasenko [Fri, 21 Jul 2017 11:20:14 +0000 (13:20 +0200)]
ash: improve set -x to quote strings as necessary

Basen on the patch from Martijn Dekker <martijn@inlv.org>

function                                             old     new   delta
evalcommand                                         1161    1302    +141
maybe_single_quote                                     -      60     +60
getoptscmd                                           527     546     +19
readtoken1                                          2819    2823      +4
localcmd                                             366     364      -2
evaltreenr                                           495     479     -16
evaltree                                             495     479     -16
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/3 up/down: 224/-34)           Total: 190 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoudhcpc[6]: on log level 1, three messages about raw socket is overkill
Denys Vlasenko [Fri, 21 Jul 2017 10:04:22 +0000 (12:04 +0200)]
udhcpc[6]: on log level 1, three messages about raw socket is overkill

Move first two messages to log2 level:

08:46:32.23824 udhcpc: opening raw socket on ifindex 2
08:46:32.23825 udhcpc: got raw socket fd
08:46:32.26354 udhcpc: created raw socket

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoping: better config help text for FEATURE_FANCY_PING
Denys Vlasenko [Fri, 21 Jul 2017 09:58:43 +0000 (11:58 +0200)]
ping: better config help text for FEATURE_FANCY_PING

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoconfig: deindent all help texts
Denys Vlasenko [Fri, 21 Jul 2017 07:50:55 +0000 (09:50 +0200)]
config: deindent all help texts

Those two spaces after tab have no effect, and always a nuisance when editing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agolibarchive: FEATURE_LZMA_FAST should be visible if FEATURE_SEAMLESS_LZMA
Denys Vlasenko [Thu, 20 Jul 2017 21:28:00 +0000 (23:28 +0200)]
libarchive: FEATURE_LZMA_FAST should be visible if FEATURE_SEAMLESS_LZMA

While at it, tweak some config help texts.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agounzip: sanitize filename length: malloc(1234mb) is not funny
Denys Vlasenko [Thu, 20 Jul 2017 18:21:50 +0000 (20:21 +0200)]
unzip: sanitize filename length: malloc(1234mb) is not funny

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agounzip: implement -j, closes 9126
Denys Vlasenko [Thu, 20 Jul 2017 18:04:49 +0000 (20:04 +0200)]
unzip: implement -j, closes 9126

function                                             old     new   delta
unzip_main                                          2642    2703     +61
packed_usage                                       31747   31770     +23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 84/0)               Total: 84 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agounzip: robustify overwrite checks
Denys Vlasenko [Thu, 20 Jul 2017 16:56:05 +0000 (18:56 +0200)]
unzip: robustify overwrite checks

function                                             old     new   delta
get_lstat_mode                                         -      55     +55
unzip_main                                          2667    2642     -25
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 55/-25)             Total: 30 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agounzip: support symlinks. Closes 10031
Denys Vlasenko [Thu, 20 Jul 2017 16:34:51 +0000 (18:34 +0200)]
unzip: support symlinks. Closes 10031

function                                             old     new   delta
unzip_main                                          2519    2667    +148

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agobzcat,zcat: simplify code if gunzip/bunzip2 is not selected
Denys Vlasenko [Thu, 20 Jul 2017 14:25:03 +0000 (16:25 +0200)]
bzcat,zcat: simplify code if gunzip/bunzip2 is not selected

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoshell: optional support for read -t N.NNN, closes 10101
Denys Vlasenko [Thu, 20 Jul 2017 14:09:31 +0000 (16:09 +0200)]
shell: optional support for read -t N.NNN, closes 10101

function                                             old     new   delta
shell_builtin_read                                  1097    1277    +180
dump_procs                                           353     359      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agobootchartd: fix typo in comment
Denys Vlasenko [Thu, 20 Jul 2017 11:42:19 +0000 (13:42 +0200)]
bootchartd: fix typo in comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agobootchartd: prevent premature stop by device mapper
Uwe Geuder [Wed, 19 Jul 2017 19:08:08 +0000 (22:08 +0300)]
bootchartd: prevent premature stop by device mapper

Kernel thread kdmflush was recognized as display manager kdm,
check for string length.

Signed-off-by: Uwe Geuder <busybox2017-ugeuder@snkmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agosparc: needs -fPIC
Denys Vlasenko [Wed, 19 Jul 2017 15:56:56 +0000 (17:56 +0200)]
sparc: needs -fPIC

Pinted out by Thomas Petazzoni.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoswapon/swapoff: trim config help text
Denys Vlasenko [Wed, 19 Jul 2017 12:39:30 +0000 (14:39 +0200)]
swapon/swapoff: trim config help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoUpdate remaining menuconfig items with approximate applet sizes
Denys Vlasenko [Wed, 19 Jul 2017 12:32:54 +0000 (14:32 +0200)]
Update remaining menuconfig items with approximate applet sizes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agood_bloaty: fix floating point output
Ron Yorston [Wed, 19 Jul 2017 09:43:10 +0000 (10:43 +0100)]
od_bloaty: fix floating point output

Currently od_bloaty does this:

   $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | busybox od -f
   od: invalid character 'F' in type string 'fF'
   $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | busybox od -t fD
   od: invalid character 'D' in type string 'fD'
   $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | busybox od -t f
   0000000
   0000010

The first two occur because the alphabetic length specifier isn't being
properly skipped.  The third is due to the empty length specifier being
treated as alphabetic so we fall off the end of the FDL_sizeof array with
undetermined consequences.  Coreutils defaults to printing a double in
this case.

With this patch the output is:

   $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | ./busybox od -f
   0000000   0.0000000e+00   0.0000000e+00
   0000010
   $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | ./busybox od -t fD
   0000000   0.000000000000000e+00
   0000010
   $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | ./busybox od -t f
   0000000   0.000000000000000e+00
   0000010

I guess nobody uses BusyBox od to print floating point numbers.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohdparm: remove contradicting size info in config help
Denys Vlasenko [Tue, 18 Jul 2017 20:25:58 +0000 (22:25 +0200)]
hdparm: remove contradicting size info in config help

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: remove contradicting size info in config help
Denys Vlasenko [Tue, 18 Jul 2017 20:25:12 +0000 (22:25 +0200)]
ash: remove contradicting size info in config help

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: remove contradicting size info in config help
Denys Vlasenko [Tue, 18 Jul 2017 20:23:55 +0000 (22:23 +0200)]
hush: remove contradicting size info in config help

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoUpdate menuconfig items with approximate applet sizes
Denys Vlasenko [Tue, 18 Jul 2017 20:01:24 +0000 (22:01 +0200)]
Update menuconfig items with approximate applet sizes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoTweaks from mass recompile for 1.27.1 release
Denys Vlasenko [Tue, 18 Jul 2017 18:17:51 +0000 (20:17 +0200)]
Tweaks from mass recompile for 1.27.1 release

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: tweak "help" output
Denys Vlasenko [Tue, 18 Jul 2017 16:14:42 +0000 (18:14 +0200)]
hush: tweak "help" output

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoprintf: fix format string sanity check
Ron Yorston [Tue, 18 Jul 2017 08:33:22 +0000 (09:33 +0100)]
printf: fix format string sanity check

One of the tests for printf checks for an invalid bare '%' in the
format string:

   $ busybox printf '%' a b c
   printf: %: invalid format

On x86_64 a slightly different test doesn't work correctly:

   $ busybox printf '%' d e f
   printf: invalid number 'd'
   printf: invalid number 'e'
   printf: invalid number 'f'

On other platforms the test fails randomly depending on how the
arguments are laid out in memory.

There are two places in the code where strchr is used to determine if
a character in the format string is valid.  However, strchr also returns
a valid pointer if the character being searched for is the null terminator
thus causing the code to incorrectly suppose that a valid character has
been found.

Add explicit checks for the null terminator.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: fix readonly2.tests failure
Denys Vlasenko [Tue, 18 Jul 2017 13:58:02 +0000 (15:58 +0200)]
hush: fix readonly2.tests failure

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: another testcase for "READONLY_VAR=VAL BLTIN ..."
Denys Vlasenko [Tue, 18 Jul 2017 01:23:07 +0000 (03:23 +0200)]
hush: another testcase for "READONLY_VAR=VAL BLTIN ..."

Currently fails.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: do not assign to readonly VAR in "VAR=VAL CMD" syntax too
Denys Vlasenko [Tue, 18 Jul 2017 00:44:06 +0000 (02:44 +0200)]
hush: do not assign to readonly VAR in "VAR=VAL CMD" syntax too

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: add readonly testcase, fix fallout
Denys Vlasenko [Mon, 17 Jul 2017 23:40:01 +0000 (01:40 +0200)]
hush: add readonly testcase, fix fallout

function                                             old     new   delta
helper_export_local                                  185     214     +29
run_pipe                                            1549    1560     +11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 40/0)               Total: 40 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: convert exp/ro/local parameters to bitfields in one flag param
Denys Vlasenko [Mon, 17 Jul 2017 23:05:24 +0000 (01:05 +0200)]
hush: convert exp/ro/local parameters to bitfields in one flag param

function                                             old     new   delta
helper_export_local                                  174     185     +11
set_local_var                                        424     420      -4
run_list                                            1048    1044      -4
set_vars_and_save_old                                 88      83      -5
set_local_var_from_halves                             27      22      -5
run_pipe                                            1554    1549      -5
builtin_export                                       173     168      -5
set_pwd_var                                           40      34      -6
builtin_readonly                                      70      64      -6
expand_one_var                                      1625    1618      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/9 up/down: 11/-47)            Total: -36 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: HUSH_READONLY depends on HUSH
Denys Vlasenko [Mon, 17 Jul 2017 19:47:27 +0000 (21:47 +0200)]
hush: HUSH_READONLY depends on HUSH

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: forgot to emit error on (failing) second "readonly VAR=VAL"
Denys Vlasenko [Mon, 17 Jul 2017 19:31:17 +0000 (21:31 +0200)]
hush: forgot to emit error on (failing) second "readonly VAR=VAL"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: smaller code in !READONLY configs
Denys Vlasenko [Mon, 17 Jul 2017 19:19:53 +0000 (21:19 +0200)]
hush: smaller code in !READONLY configs

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: implement "readonly" builtin
Denys Vlasenko [Mon, 17 Jul 2017 19:10:50 +0000 (21:10 +0200)]
hush: implement "readonly" builtin

function                                             old     new   delta
builtin_readonly                                       -      70     +70
helper_export_local                                  152     174     +22
bltins1                                              348     360     +12
expand_one_var                                      1620    1625      +5
builtin_export                                       168     173      +5
set_pwd_var                                           36      40      +4
set_local_var                                        410     414      +4
set_vars_and_save_old                                 85      88      +3
set_local_var_from_halves                             24      27      +3
run_pipe                                            1551    1554      +3
run_list                                            1046    1048      +2
builtin_type                                         116     114      -2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 10/1 up/down: 133/-2)           Total: 131 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: more general format ${var:EXPR:EXPR}
Denys Vlasenko [Mon, 17 Jul 2017 15:49:11 +0000 (17:49 +0200)]
ash: more general format ${var:EXPR:EXPR}

function                                             old     new   delta
subevalvar                                          1171    1202     +31
localcmd                                             364     366      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: "you disabled math" is wrong: user did not disable it, builder of ash did
Denys Vlasenko [Mon, 17 Jul 2017 15:11:48 +0000 (17:11 +0200)]
ash: "you disabled math" is wrong: user did not disable it, builder of ash did

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: small fix to last commit
Denys Vlasenko [Mon, 17 Jul 2017 14:50:20 +0000 (16:50 +0200)]
hush: small fix to last commit

die_if_script() indeed dies only in scripts! Must handle the case where it continues.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: support ${VAR:N:-M}
Denys Vlasenko [Mon, 17 Jul 2017 14:46:57 +0000 (16:46 +0200)]
hush: support ${VAR:N:-M}

function                                             old     new   delta
expand_one_var                                      1602    1615     +13
builtin_type                                         114     116      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoshells: expand TODO comments, no code changes
Denys Vlasenko [Mon, 17 Jul 2017 14:13:35 +0000 (16:13 +0200)]
shells: expand TODO comments, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agottysize: if stdin is not tty, try stdout, then stderr
Denys Vlasenko [Sun, 16 Jul 2017 18:36:48 +0000 (20:36 +0200)]
ttysize: if stdin is not tty, try stdout, then stderr

function                                             old     new   delta
ttysize_main                                         135     175     +40
packed_usage                                       31686   31672     -14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: fix "cmd1 && cmd2 &" handling on NOMMU
Denys Vlasenko [Sun, 16 Jul 2017 18:29:35 +0000 (20:29 +0200)]
hush: fix "cmd1 && cmd2 &" handling on NOMMU

function                                             old     new   delta
done_pipe                                            234     238      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoarch: new applet (same as unmae -m). ~30 bytes.
Denys Vlasenko [Sun, 16 Jul 2017 14:43:41 +0000 (16:43 +0200)]
arch: new applet (same as unmae -m). ~30 bytes.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoshell: and_or_and_backgrounding.tests is no longer "UNFIXED BUG"
Denys Vlasenko [Sat, 15 Jul 2017 20:54:46 +0000 (22:54 +0200)]
shell: and_or_and_backgrounding.tests is no longer "UNFIXED BUG"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: fix and_or_and_backgrounding.tests failure
Denys Vlasenko [Sat, 15 Jul 2017 20:51:55 +0000 (22:51 +0200)]
hush: fix and_or_and_backgrounding.tests failure

function                                             old     new   delta
done_pipe                                            133     218     +85

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoconfig: reorder items in "Busybox Settings", improve help
Denys Vlasenko [Sat, 15 Jul 2017 19:14:16 +0000 (21:14 +0200)]
config: reorder items in "Busybox Settings", improve help

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoconfig: merge "Busybox Settings" and "Busybox Library Tuning" into one menu
Denys Vlasenko [Sat, 15 Jul 2017 18:49:32 +0000 (20:49 +0200)]
config: merge "Busybox Settings" and "Busybox Library Tuning" into one menu

Tweak a few help texts while at it

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoMove get_unaligned_le32() macros to platform.h
Denys Vlasenko [Sat, 15 Jul 2017 18:22:25 +0000 (20:22 +0200)]
Move get_unaligned_le32() macros to platform.h

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agofix more instances of ": $((a++))" in shell scripts
Denys Vlasenko [Sat, 15 Jul 2017 17:18:58 +0000 (19:18 +0200)]
fix more instances of ": $((a++))" in shell scripts

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomake_single_applets: fix ": $((fail++))" expansion error
Kang-Che Sung [Sat, 15 Jul 2017 03:38:58 +0000 (11:38 +0800)]
make_single_applets: fix ": $((fail++))" expansion error

$((fail++)) is not a required expression in POSIX, and in "dash" it
could produce an error like this:

    ./make_single_applets.sh: 61: arithmetic expression: expecting primary: "fail++"

Replace this with something portable: fail=$((fail+1)) would work.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoconfig: fix tab-damaged help text
Denys Vlasenko [Sat, 15 Jul 2017 15:34:33 +0000 (17:34 +0200)]
config: fix tab-damaged help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: remove last int16 local variables in pstm code
Denys Vlasenko [Sat, 15 Jul 2017 15:19:38 +0000 (17:19 +0200)]
tls: remove last int16 local variables in pstm code

function                                             old     new   delta
pstm_mul_comba                                       439     447      +8
pstm_sqr_comba                                       475     478      +3
pstm_montgomery_reduce                               399     381     -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 11/-18)             Total: -7 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: fix pstm asm constraint problem
Denys Vlasenko [Sat, 15 Jul 2017 15:13:08 +0000 (17:13 +0200)]
tls: fix pstm asm constraint problem

function                                             old     new   delta
pstm_sqr_comba                                       551     475     -76

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agobuild system: FEATURE_LIBBUSYBOX_STATIC - try to pull libc/libm into libbusybox
Denys Vlasenko [Sat, 15 Jul 2017 12:52:26 +0000 (14:52 +0200)]
build system: FEATURE_LIBBUSYBOX_STATIC - try to pull libc/libm into libbusybox

It variously fails with different toolchains I tried...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoblkdiscard: provide our own BLK[SEC]DISCARD if necessary
Denys Vlasenko [Sat, 15 Jul 2017 11:53:41 +0000 (13:53 +0200)]
blkdiscard: provide our own BLK[SEC]DISCARD if necessary

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: fix build problem on non-static i386
Denys Vlasenko [Sat, 15 Jul 2017 11:42:19 +0000 (13:42 +0200)]
tls: fix build problem on non-static i386

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoMakefile: include per-arch Makefile before Makefile.flags
Thomas Petazzoni [Fri, 14 Jul 2017 21:08:38 +0000 (23:08 +0200)]
Makefile: include per-arch Makefile before Makefile.flags

Makefile.flags contains:

ARCH_FPIC ?= -fpic
ARCH_FPIE ?= -fpie

However, arch/$(ARCH)/Makefile gets included *after* Makefile.flags,
and therefore doesn't get the chance to provide its own value.

Fix this by including arch/$(ARCH)/Makefile *before* Makefile.flags.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agocopyfd: guard use of munmap() with #if (windows builds need this)
Johannes Schindelin [Fri, 14 Jul 2017 14:11:43 +0000 (16:11 +0200)]
copyfd: guard use of munmap() with #if (windows builds need this)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: protect WIFSTOPPED use with #if JOBS
Johannes Schindelin [Fri, 14 Jul 2017 20:25:58 +0000 (22:25 +0200)]
ash: protect WIFSTOPPED use with #if JOBS

This change fixes the build in setups where there are
no headers defining WIFSTOPPED and WSTOPSIG (where JOBS has to be
set to 0).

This partially reverts 4700fb5be (ash: make dowait() a bit more
readable. Logic is unchanged, 2015-10-09).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agolibbb: hide getnetbyaddr() inside "#if ENABLE_FEATURE_ETC_NETWORKS" block
Denys Vlasenko [Fri, 14 Jul 2017 18:17:17 +0000 (20:17 +0200)]
libbb: hide getnetbyaddr() inside "#if ENABLE_FEATURE_ETC_NETWORKS" block

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: make "wait %1" work even if the job is dead
Denys Vlasenko [Fri, 14 Jul 2017 17:58:46 +0000 (19:58 +0200)]
hush: make "wait %1" work even if the job is dead

Example script:

sleep 1 | (sleep 1;exit 3) &
sleep 2
echo Zero:$?
wait %1
echo Three:$?

function                                             old     new   delta
clean_up_last_dead_job                                 -      24     +24
process_wait_result                                  426     447     +21
builtin_wait                                         285     293      +8
insert_job_into_table                                264     269      +5
builtin_jobs                                          68      73      +5
remove_job_from_table                                 59      57      -2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/1 up/down: 63/-2)              Total: 61 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: remove superfluous comparison
Denys Vlasenko [Fri, 14 Jul 2017 17:27:03 +0000 (19:27 +0200)]
hush: remove superfluous comparison

function                                             old     new   delta
builtin_wait                                         291     285      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agouuencode: allow space instead of "`" as padding char. Closes 10046
Denys Vlasenko [Fri, 14 Jul 2017 15:24:59 +0000 (17:24 +0200)]
uuencode: allow space instead of "`" as padding char. Closes 10046

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoxxd: allow "-" as file name meaning stdin
Denys Vlasenko [Fri, 14 Jul 2017 14:29:30 +0000 (16:29 +0200)]
xxd: allow "-" as file name meaning stdin

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agolibbb/dump: allow skipping over stdin too
Denys Vlasenko [Fri, 14 Jul 2017 14:18:16 +0000 (16:18 +0200)]
libbb/dump: allow skipping over stdin too

function                                             old     new   delta
next                                                 294     265     -29

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agolibbb/dump: fix a few broken commits and shrink code
Denys Vlasenko [Fri, 14 Jul 2017 14:03:43 +0000 (16:03 +0200)]
libbb/dump: fix a few broken commits and shrink code

function                                             old     new   delta
next                                                 310     294     -16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agolibbb: safe_write should not return EINTR
Denys Vlasenko [Fri, 14 Jul 2017 12:22:09 +0000 (14:22 +0200)]
libbb: safe_write should not return EINTR

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agodd: fix status=none. Closes 10066
Denys Vlasenko [Fri, 14 Jul 2017 11:44:30 +0000 (13:44 +0200)]
dd: fix status=none. Closes 10066

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohush: add support for "set -e"
Denys Vlasenko [Fri, 14 Jul 2017 11:36:48 +0000 (13:36 +0200)]
hush: add support for "set -e"

function                                             old     new   delta
run_list                                             978    1046     +68
o_opt_strings                                         24      32      +8
reset_traps_to_defaults                              136     142      +6
pick_sighandler                                       57      60      +3
packed_usage                                       31772   31770      -2
hush_main                                            983     961     -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/2 up/down: 85/-24)             Total: 61 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agocat: fix "cat -An" ignoring -n; make numbering go througn all files
Denys Vlasenko [Fri, 14 Jul 2017 08:47:18 +0000 (10:47 +0200)]
cat: fix "cat -An" ignoring -n; make numbering go througn all files

function                                             old     new   delta
cat_main                                             418     428     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>