Denys Vlasenko
0dd8e45d42
ash: [EXPAND] Optimise nulonly away and just use quoted as before
...
Upstream commit:
Date: Wed, 8 Oct 2014 20:09:56 +0800
[EXPAND] Optimise nulonly away and just use quoted as before
This patch makes a small optimisation by using the same value for
quoted between evalvar and varvalue by eliminating nulonly and
passing along quoted instead.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 21:02:06 +02:00
Denys Vlasenko
88ac97d02d
ash: [EXPAND] Do not split quoted VSLENGTH and VSTRIM
...
Upstream patch:
Date: Wed, 8 Oct 2014 15:42:08 +0800
[EXPAND] Do not split quoted VSLENGTH and VSTRIM
Currently VSLENGTH and VSTRIM* are field-split even within quotes.
This is obviously wrong. This patch fixes that.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 20:55:02 +02:00
Denys Vlasenko
c4d4380a07
ash: [EXPAND] Split unquoted $@/$* correctly when IFS is set but empty
...
Upstream commit:
Date: Wed, 8 Oct 2014 15:24:23 +0800
[EXPAND] Split unquoted $@/$* correctly when IFS is set but empty
Currently we do not field-split $@/$* when it isn't quoted and IFS
is set but empty. This is obviously wrong. This patch fixes this.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 20:35:10 +02:00
Denys Vlasenko
a2633aa819
hush: add func6.tests
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 20:12:10 +02:00
Denys Vlasenko
35ec818fa2
ash: fix "return N" not setting $? in loop conditionals
...
Upstream commit 1:
Date: Mon, 6 Oct 2014 20:45:04 +0800
[EVAL] Move common skipcount logic into skiploop
The functions evalloop and evalfor share the logic on checking
and updating skipcount. This patch moves that into the helper
function skiploop.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Upstream commit 2:
Date: Mon, 6 Oct 2014 21:22:43 +0800
[BUILTIN] Allow return in loop conditional to set exit status
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=332954
When return is used in a loop conditional the exit status will
be lost because we always set the exit status at the end of the
loop to that of the last command executed in the body.
This is counterintuitive and contrary to what most other shells do.
This patch fixes this by always preserving the exit status of
return when it is used in a loop conditional.
The patch was originally written by Gerrit Pape <pape@smarden.org>.
Reported-by: Stephane Chazelas <stephane_chazelas@yahoo.fr>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 19:56:52 +02:00
Denys Vlasenko
1b8e0e8adf
ash testsuite: remove two more inadvertent bashisms
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 17:43:04 +02:00
Denys Vlasenko
cc0056db5c
ash testsuite: remove two inadvertent bashisms
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 17:30:21 +02:00
Denys Vlasenko
4d12e944ea
ash: [ERROR] Set exitstatus in onint
...
Partially backported this commit:
Date: Thu, 2 Oct 2014 21:07:55 +0800
[ERROR] Set exitstatus in onint
Currently the exit status when we receive SIGINT is set in evalcommand
which means that it doesn't always get set. For example, if you press
CTRL-C at the prompt of an interactive dash, the exit status is not
set to 130 as it is in many other Bourne shells.
This patch fixes this by moving the setting of the exit status into
onint which also simplifies evalcommand.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
The part after "if (evalbltin(cmdentry.u.cmd, argc, argv, flags))"
causes testsuite failures in signal handling, so left unchanged.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 16:03:11 +02:00
Denys Vlasenko
0840c91909
ash: [EVAL] Revert SKIPEVAL into EXEXIT
...
Upstream commit:
Date: Tue Aug 11 20:56:53 2009 +1000
[EVAL] Revert SKIPEVAL into EXEXIT
Now that eval handles EV_TESTED correctly, we can remove the
SKIPEVAL hack and simply use EXEXIT for set -e.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 15:27:44 +02:00
Denys Vlasenko
7b3fa1e441
ash: [EVAL] Pass EV_TESTED into evalcmd
...
Upstream commit:
Date: Tue Aug 11 20:48:15 2009 +1000
[EVAL] Pass EV_TESTED into evalcmd
This patch fixes the case where the eval command is used with
set -e and as part of a construct that should not cause the
shell to abort, e.g., as part of the condition of an if statement.
This is achieved by propagating the EV_TESTED flag into the
evalstring function through evalcmd. As this alters the prototype
of evalcmd it is now invoked explicitly by evalbltin. The built-in
infrastructure has been changed to accomodate this special case.
In order to ensure that the EXIT trap is properly executed this
patch clears evalskip in exitshell. This wasn't needed before
because of the broken way evalstring worked where it always clears
evalskip when called by minusc.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Although, I failed to create a reproducer for this.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 15:10:16 +02:00
Denys Vlasenko
08089c7c85
ash: fix a thinko in the last commit
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 14:47:52 +02:00
Denys Vlasenko
514b51ddf3
ash: make internal globbing code selectable from config
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 14:33:08 +02:00
Denys Vlasenko
cac4d002e7
ash: explain how "command" is handled, and shrink it a bit
...
function old new delta
getoptscmd 641 632 -9
commandcmd 79 69 -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-19) Total: -19 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01 03:02:25 +02:00
Denys Vlasenko
e627ac95be
ash: [VAR] Initialise OPTIND after importing environment
...
Upstream commit 1:
Date: Fri, 23 Aug 2013 21:27:42 +1000
[VAR] Initialise OPTIND after importing environment
On Sat, Mar 23, 2013 at 01:46:20AM +0000, Chris F.A. Johnson wrote:
> According to both the dash man page and the POSIX spec, "When the
> shell is invoked, OPTIND is initialized to 1."
>
> However, it actually takes the value of the environment variable
> if it exists:
>
> $ OPTIND=4 dash -c 'echo "$OPTIND"'
> 4
> $ OPTIND=4 bash -c 'echo "$OPTIND"'
> 1
> $ OPTIND=4 ksh -c 'echo "$OPTIND"'
> 1
> $ OPTIND=4 ksh93 -c 'echo "$OPTIND"'
> 1
This patch fixes this by initialising OPTIND after importing the
environment.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Upstream commit 2:
Date: Tue, 7 Oct 2014 22:24:42 +0800
[VAR] Use setvareq to set OPTIND initially
There is no need to setvarint to set the initial value of OPTIND
of one. This patch switchs to setvareq which also lets us avoid
an unnecessary memory allocation.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 14:46:41 +02:00
Denys Vlasenko
6a0710e954
ash: [BUILTIN] Merge SKIPFUNC/SKIPFILE and only clear SKIPFUNC when leaving dotcmd
...
Upstream commit:
Date: Sat, 9 Jul 2011 22:05:22 +0800
[BUILTIN] Merge SKIPFUNC/SKIPFILE and only clear SKIPFUNC when leaving dotcmd
Currently upon leaving a dotcmd the evalskip state is reset so
if a continue/break statement is used within a dot script it would
have no effect outside of the dot script.
This is inconsistent with other shells.
This patch is based on one by Jilles Tjoelker and only clears
SKIPFUNC when leaving a dot script. As a result continue/break
will remain in effect.
It also merges SKIPFUNC/SKIPFILE as they have no practical difference.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 14:46:41 +02:00
Denys Vlasenko
ed6ff5edfc
hush: enable "msh is deprecated" message in msh stub
...
After giving a few more years for everyone to notice and migrate,
can nuke all remains of msh.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 12:28:37 +02:00
Denys Vlasenko
50e6d42c19
ash: Avoid overflow for very long variable name
...
Upstream commit:
Date: Tue, 3 Jul 2012 17:32:33 +0800
Avoid overflow for very long variable name
Otherwise, this:
$ perl -le 'print "v"x(2**31+1) ."=1"' | dash
provokes integer overflow
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 11:35:54 +02:00
Denys Vlasenko
b6838b520a
ash: [VAR] Sanitise environment variable names on entry
...
Upstream commit:
Date: Sat, 25 Feb 2012 15:35:18 +0800
[VAR] Sanitise environment variable names on entry
On Tue, Feb 14, 2012 at 10:48:48AM +0000, harald@redhat.com wrote:
> "export -p" prints all environment variables, without checking if the
> environment variable is a valid dash variable name.
>
> IMHO, the only valid usecase for "export -p" is to eval the output.
>
> $ eval $(export -p); echo OK
> OK
>
> Without this patch the following test does error out with:
>
> test.py:
> import os
> os.environ["test-test"]="test"
> os.environ["test_test"]="test"
> os.execv("./dash", [ './dash', '-c', 'eval $(export -p); echo OK' ])
>
> $ python test.py
> ./dash: 1: export: test-test: bad variable name
>
> Of course the results can be more evil, if the environment variable
> name is crafted, that it injects valid shell code.
This patch fixes the issue by sanitising all environment variable names
upon entry into the shell.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 11:33:47 +02:00
Denys Vlasenko
a2d121cc1b
ash: [EVAL] Avoid using undefined handler
...
Upstream commit:
Date: Fri, 8 Jul 2011 16:41:24 +0800
[EVAL] Avoid using undefined handler
* src/eval.c (evalbltin, evalfun): Set savehandler before calling
setjmp with the possible "goto *done", where savehandler is used.
Otherwise, clang warns that "Assigned value is garbage or undefined"
at the point where "savehandler" is used on the RHS.
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 11:30:11 +02:00
Denys Vlasenko
53d6e03a0a
ash: remove dead stores and unused variables
...
Upstream commit 1:
Date: Fri, 8 Jul 2011 16:12:20 +0800
[MEMALLOC] Avoid gcc warning: variable 'oldstackp' set but not used
* src/memalloc.c (growstackblock): Remove declaration and set of
set-but-not-used variable. Also remove a stray space-before-TAB.
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Upstream commit 2:
Date: Fri, 8 Jul 2011 16:16:11 +0800
[MEMALLOC] Avoid clang warning about dead store to "size"
* src/memalloc.c (makestrspace): Remove dead store.
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 11:24:12 +02:00
Denys Vlasenko
60ca834358
ash: [MEMALLOC] Add pushstackmark
...
Upstream commit:
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date: Sat Oct 6 00:45:52 2007 +0800
[MEMALLOC] Add pushstackmark
This patch gets rid of the stack mark tracking hack by allocating a little
bit of stack memory if we're at risk of planting a stack mark which may be
grown later. To do this a new function pushstackmark is added which lets
the user pick a bigger amount to allocate since some users do that anyway
after setting a stack mark.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 11:21:21 +02:00
Denys Vlasenko
08755f9bcb
hush: fix typo in comment
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 02:02:25 +02:00
Denys Vlasenko
4074d49557
hush: fix interactive input handling of backslash+newline
...
function old new delta
fgetc_interactive - 258 +258
i_peek_and_eat_bkslash_nl 43 93 +50
static_peek2 7 - -7
setup_string_in_str 46 39 -7
setup_file_in_str 47 40 -7
file_peek 72 52 -20
expand_vars_to_list 1167 1143 -24
file_peek2 74 - -74
file_get 326 65 -261
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 1/5 up/down: 308/-400) Total: -92 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-30 01:49:53 +02:00
Denys Vlasenko
0448c55cc8
hush: G.user_input_buf[] is needed only if line editing is enabled
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 20:25:44 +02:00
Denys Vlasenko
7a24e8ffeb
shell testsuite: add trailing newline to var_unbackslash1.tests
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 20:02:53 +02:00
Denys Vlasenko
46e6498b2a
hush: speed optimizations
...
Make o_addchr() faster: do not call o_grow_by() each time.
Create i_getch_and_eat_bkslash_nl(), use it instead of peek+getch pair.
function old new delta
o_addchr 42 54 +12
parse_dollar 761 771 +10
o_grow_by 48 37 -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 24/-11) Total: 11 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 19:50:55 +02:00
Denys Vlasenko
657086a3dc
hush: fix handling of by backslash-newline in $((arith)) and $(cmd)
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 18:07:42 +02:00
Denys Vlasenko
d17a91db6e
hush: rework input char buffering to allow more than one-deep peek
...
...this time with actual hush.c changes too :)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 18:02:37 +02:00
Denys Vlasenko
459293b1c5
ash: fix arithmetic closing )) split by backslash-newline
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 17:58:58 +02:00
Denys Vlasenko
73c3e074df
ash: [PARSER] Handle backslash newlines properly after dollar sign
...
Fixes var_unbackslash1.tests failure.
Upstream commit:
[PARSER] Handle backslash newlines properly after dollar sign
On Tue, Aug 26, 2014 at 12:34:42PM +0000, Eric Blake wrote:
> On 08/26/2014 06:15 AM, Oleg Bulatov wrote:
> > While playing with sh generators I found that dash and bash have different
> > interpretations for <slash><newline> sequence.
> >
> > $ dash -c 'EDIT=xxx; echo $EDIT\
> >> OR'
> > xxxOR
>
> Buggy.
> >
> > $ dash -c 'echo "$\
> > (pwd)"'
> > $(pwd)
> >
> > Is it undefined behaviour in POSIX?
>
> No, it's well-defined, and dash is buggy.
...
I agree. This patch should resolve this problem and similar ones
affecting blackslash newlines after we encounter a dollar sign.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 17:17:04 +02:00
Denys Vlasenko
8286513838
hush: rework input char buffering to allow more than one-deep peek
...
This fixes backslash+newline continuation in
$VAR\
NAME
construct. (ash has a bug there as well).
function old new delta
file_peek2 - 74 +74
parse_dollar 746 773 +27
expand_vars_to_list 1143 1167 +24
setup_string_in_str 32 46 +14
setup_file_in_str 33 47 +14
file_get 264 278 +14
static_peek2 - 7 +7
file_peek 91 72 -19
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 5/1 up/down: 174/-19) Total: 155 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 16:59:06 +02:00
Denys Vlasenko
3b4d04b77e
ash: input: Allow two consecutive calls to pungetc
...
Upstream commit:
input: Allow two consecutive calls to pungetc
The commit ef91d3d6a4c39421fd3a391e02cd82f9f3aee4a8 ([PARSER]
Handle backslash newlines properly after dollar sign) created
cases where we make two consecutive calls to pungetc. As we
don't explicitly support that there are corner cases where you
end up with garbage input leading to undefined behaviour.
This patch adds explicit support for two consecutive calls to
pungetc.
Reported-by: Jilles Tjoelker <jilles@stack.nl>
Reported-by: Juergen Daubert <jue@jue.li>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
In bbox case, bashism >& may need two pungetc() too.
function old new delta
pgetc 514 555 +41
pushstring 114 144 +30
basepf 52 76 +24
popstring 134 151 +17
parse_command 1584 1585 +1
pungetc 12 9 -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/1 up/down: 113/-3) Total: 110 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 02:11:19 +02:00
Denys Vlasenko
78c9c736ab
hush: fix 'eval ""' handling
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 01:44:17 +02:00
Denys Vlasenko
992e0ff7e9
hush: fix ". EMPTY_LINE" not setting $? to 0
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 01:27:09 +02:00
Denys Vlasenko
46a45ce02f
ash: jobs: Don't attempt to access job table for job %0
...
Upstream commit:
jobs: Don't attempt to access job table for job %0
If job %0 is (mistakenly) specified, an out-of-bounds access to the
jobtab occurs in function getjob() if num = 0:
jp = jobtab + 0 - 1
Fix this by checking that the job number is larger than 0 before
accessing the jobtab.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 01:10:08 +02:00
Denys Vlasenko
928e2a7ef4
ash: [EVAL] Make eval with empty arguments return 0
...
This is a backport of upstream commit:
[EVAL] Make eval with empty arguments return 0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 00:30:31 +02:00
Denys Vlasenko
8e2bc47d62
ash: [EVAL] Fix use-after-free in dotrap/evalstring
...
From upstream:
[EVAL] Fix use-after-free in dotrap/evalstring
The function dotrap calls evalstring using the stored trap string.
If evalstring then unsets that exact trap string then we will end
up using freed memory.
This patch fixes it by making evalstring always duplicate the string
before using it.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-28 23:02:57 +02:00
Denys Vlasenko
7ee7c6fc20
ash: Remove unused EV_BACKCMD flag
...
The original ash defered forking commands in backquotes so builtins
could be run in the same context as the shell. This behavior was
controlled using the EV_BACKCMD to evaltree.
Unfortunately, as Matthias Scheler noticed in 1999 (NetBSD PR/7814),
the result was counterintuitive; for example, echo "`cd /`" would
change the cwd. So ash 0.3.5 left out that optimization.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-28 19:44:16 +02:00
Denys Vlasenko
eb17b6f6c9
ash: eval: Return status in eval functions
...
Backported from dash:
eval: Return status in eval functions
The exit status is currently clobbered too early for case statements
and loops. This patch fixes it by making the eval functions return
the current exit status and setting them in one place -- evaltree.
Harald van Dijk pointed out a number of bugs in the original patch.
function old new delta
evalcommand 1226 1242 +16
cmdloop 383 398 +15
evalfor 223 227 +4
evalcase 271 275 +4
localcmd 348 350 +2
evaltreenr 927 928 +1
evaltree 927 928 +1
evalsubshell 150 151 +1
evalpipe 356 357 +1
parse_command 1585 1584 -1
evalloop 177 164 -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 9/2 up/down: 45/-14) Total: 31 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-28 19:41:57 +02:00
Denys Vlasenko
557482c1cb
ash: in heredoc code, fix access past the end of allocated memory. Closes 9276
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-25 21:24:04 +02:00
Denys Vlasenko
13f20919b2
ash: fix handling of NULs in $'abc\000def\x00asd'. Closes 9286
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-25 20:54:25 +02:00
Denys Vlasenko
b3f29b452a
ash: use glob() from libc
...
Adapted from dash.
The "homegrown" glob code is retained (ifdef'ed out).
This changes was inspired by bug 9261, which detected out-of bounds use of heap
for 2098 byte long name in the "homegrown" code. This is still not fixed...
function old new delta
expandarg 960 982 +22
static.syntax_index_table 26 25 -1
static.spec_symbls 27 26 -1
static.metachars 4 - -4
addfname 42 - -42
msort 126 - -126
expmeta 528 - -528
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 1/2 up/down: 22/-702) Total: -680 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-21 16:25:58 +02:00
Denys Vlasenko
244fdd45c7
ash: fix handling of bashism $'xxx' with high-bit chars. Closes 9236
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-20 17:04:09 +02:00
Denys Vlasenko
d6a37d86ba
hush: document better where bad redirect syntax is detected
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-20 16:22:24 +02:00
Rostislav Skudnov
204c7fb229
ash: exit after subshell error when errexit option is set
...
When "set -e" option is on, shell must exit when any command fails,
including compound commands of the form (compound-list) executed in a
subshell. Bash and dash shells have this behaviour.
Also add a corresponding testcase.
Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-17 23:28:23 +02:00
Denys Vlasenko
7373759947
fix "aloc" -> "alloc" typos
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-17 20:58:22 +02:00
Denys Vlasenko
7bc3d39695
ash: add a FIXME for bug 9246
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-17 20:53:47 +02:00
Denys Vlasenko
ef15970d7e
*: placate some compile warnings on OSX
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-01 11:16:22 +02:00
Denys Vlasenko
aa3576a29b
hush: fix "redirects can close script fd" bug
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-22 19:54:12 +02:00
Denys Vlasenko
7b25b1c5b2
hush: do not leak script fds into NOEXEC children
...
We set all opened script fds to CLOEXEC, thus making then go away
after fork+exec.
Unfortunately, CLOFORK does not exist. NOEXEC children will still see those fds open.
For one, "ls" applet is NOEXEC. Therefore running "ls -l /proc/self/fd"
in a script from standalone shell shows this:
lrwx------ 1 root root 64 Aug 20 15:17 0 -> /dev/pts/3
lrwx------ 1 root root 64 Aug 20 15:17 1 -> /dev/pts/3
lrwx------ 1 root root 64 Aug 20 15:17 2 -> /dev/pts/3
lr-x------ 1 root root 64 Aug 20 15:17 3 -> /path/to/top/level/script
lr-x------ 1 root root 64 Aug 20 15:17 4 -> /path/to/sourced/SCRIPT1
...
with as many open fds as there are ". SCRIPTn" nest levels.
Fix it by closing these fds after fork (only for NOEXEC children).
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-20 15:58:34 +02:00
Denys Vlasenko
869994cf4f
hush: bit better comments in redirect code. No logic changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-20 15:16:00 +02:00
Denys Vlasenko
e9abe75fda
hush: cmd
and arithmetic also need the fix for FILE rewind
...
Discovered by running testsuite with a newest glibc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-19 20:15:26 +02:00
Denys Vlasenko
215b0ca6e4
hush: fix a bug in FEATURE_SH_STANDALONE=y config. Closes 9186
...
Run this in a "sh SCRIPT":
sha256sum /dev/null
echo END
sha256sum is a NOEXEC applet. It runs in a forked child. Then child exit()s.
By this time, entire script is read, and buffered in a FILE object
from fopen("SCRIPT"). But fgetc() did not consume entire input.
exit() lseeks back by -9 bytes, from <eof> to 'e' in 'echo'.
(this may be libc-specific).
This change of fd position *is shared with the parent*!
Now parent can read more, and it thinks there is another "echo END".
End result: two "echo END"s are run.
Fix this by _exit()ing instead.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-19 18:43:06 +02:00
Denys Vlasenko
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
Denys Vlasenko
52e460b744
hush: move shell_ver from globals to main's stack.
...
function old new delta
hush_main 995 1011 +16
pseudo_exec_argv 253 251 -2
execvp_or_die 50 48 -2
maybe_set_to_sigexit 50 47 -3
hush_exit 78 75 -3
builtin_wait 274 271 -3
check_and_run_traps 205 200 -5
init_sigmasks 214 190 -24
builtin_trap 465 441 -24
reset_traps_to_defaults 238 211 -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/9 up/down: 16/-93) Total: -77 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-16 16:12:00 +02:00
Denys Vlasenko
bed7c81ea2
shell/math: deconvolute and explain ?: handling. Give better error message
...
function old new delta
arith_apply 1271 1283 +12
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-16 11:50:46 +02:00
Denys Vlasenko
063847d6bd
shell/math: return string error indicator, not integer
...
function old new delta
expand_and_evaluate_arith 87 106 +19
expand_one_var 1563 1570 +7
arith 12 18 +6
evaluate_string 678 680 +2
arith_apply 1269 1271 +2
builtin_umask 133 132 -1
ash_arith 118 75 -43
expand_vars_to_list 1094 1038 -56
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/3 up/down: 36/-100) Total: -64 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-15 13:33:02 +02:00
Denys Vlasenko
0eac8ff164
shell/math.c: stop using bss variable
...
function old new delta
evaluate_string - 678 +678
expand_one_var 1543 1563 +20
builtin_type 114 116 +2
expand_and_evaluate_arith 89 87 -2
prev_chk_var_recursive 4 - -4
ash_arith 122 118 -4
arith_lookup_val 142 132 -10
arith 674 12 -662
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/4 up/down: 700/-682) Total: 18 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-13 12:49:52 +02:00
Denys Vlasenko
06d44d7dfb
shell/math.c: rename arith_eval_hooks to arith_state, put error code into it
...
function old new delta
expand_and_evaluate_arith 79 89 +10
arith 675 674 -1
arith_lookup_val 151 142 -9
ash_arith 135 122 -13
arith_apply 1304 1269 -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 10/-58) Total: -48 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-13 12:49:03 +02:00
Denys Vlasenko
bd14770b0c
shell/math.c: small code shrink; fixed incomprehensible comments
...
function old new delta
arith_apply 1334 1304 -30
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-13 11:11:40 +02:00
Denys Vlasenko
51850c818c
shell: small code shrink
...
function old new delta
arith 680 675 -5
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-13 01:09:11 +02:00
Denys Vlasenko
b771c654ca
shell: shrink arith code; and prepare for returning text error codes
...
function old new delta
arith 701 680 -21
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-13 00:34:26 +02:00
Denys Vlasenko
99862cbfad
hush: optional support for history saving
...
function old new delta
hush_main 945 995 +50
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 17:34:13 +02:00
Denys Vlasenko
de8c3f667a
hush: move the EXIT trap comment. no code changes
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 16:13:44 +02:00
Denys Vlasenko
a110c90de2
hush: fix EXIT trap display inside exit trap handler
...
function old new delta
hush_exit 84 78 -6
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 15:38:04 +02:00
Denys Vlasenko
2d8187c139
shell/match.c: shrink by dropping double bool inversion
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 15:06:42 +02:00
Denys Vlasenko
acd5bc8f64
hush: fix handling of \" in quoted/unquoted cmd
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 15:05:39 +02:00
Denys Vlasenko
958581a8d9
ash: shrink by folding an if check into setprompt; unindent big block
...
function old new delta
setprompt_if - 66 +66
parseheredoc 126 124 -2
parsecmd 68 66 -2
redirect 1254 1249 -5
xxreadtoken 351 343 -8
readtoken1 3219 3204 -15
setprompt 62 - -62
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/5 up/down: 66/-94) Total: -28 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 15:04:27 +02:00
Denys Vlasenko
6040fe88f4
ash: add missing casts to match CTLfoo; add TODO comments
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 15:03:16 +02:00
Denys Vlasenko
5277a9db70
hush: remove forgotten commented-out block. no code changes
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 15:34:53 +02:00
Denys Vlasenko
4f870496e7
hush: do fewer strdups in % and hash expansions
...
function old new delta
builtin_umask 133 132 -1
expand_one_var 1552 1543 -9
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 11:06:01 +02:00
Denys Vlasenko
d98e5c65c3
hush: better function and parameter names
...
Also, trim code which isn't needed for non-bash compat.
No logic changes.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:44:23 +02:00
Denys Vlasenko
cc461736d6
hush: fixes to testsuite
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:19:22 +02:00
Denys Vlasenko
ebee410fe2
hush: fix var_bash5.tests failure
...
function old new delta
expand_one_var 1513 1552 +39
expand_pseudo_dquoted 118 135 +17
expand_string_to_string 110 126 +16
setup_heredoc 298 308 +10
expand_and_evaluate_arith 69 79 +10
parse_stream_dquoted 233 241 +8
setup_redirects 220 225 +5
run_list 956 961 +5
expand_assignments 76 81 +5
run_pipe 1587 1590 +3
parse_stream 2371 2374 +3
builtin_umask 132 133 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 12/0 up/down: 122/0) Total: 122 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:17:53 +02:00
Denys Vlasenko
14e289b324
hush: fix var_bash3.tests failure
...
function old new delta
expand_one_var 1513 1538 +25
parse_stream_dquoted 233 241 +8
expand_pseudo_dquoted 118 126 +8
setup_heredoc 298 303 +5
expand_and_evaluate_arith 69 74 +5
parse_stream 2371 2374 +3
builtin_umask 132 133 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/0 up/down: 55/0) Total: 55 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:15:18 +02:00
Denys Vlasenko
a769e0225d
hush: remove useless ESC_GLOB_CHARS clears/resotres
...
function old new delta
o_addQstr 43 165 +122
expand_on_ifs 210 189 -21
expand_vars_to_list 1122 1094 -28
o_addqblock 139 - -139
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/2 up/down: 122/-188) Total: -66 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:12:34 +02:00
Denys Vlasenko
bfc02a76c5
hush: fix a bug where expand_one_var wasn't restoring 1st char of the encoded $var
...
function old new delta
expand_one_var 1515 1513 -2
expand_vars_to_list 1133 1122 -11
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 14:38:46 +02:00
Denys Vlasenko
101a4e3e21
hush: make parse_dollar flag quited status regardless of glob escaping status
...
function old new delta
parse_stream_dquoted 228 233 +5
parse_stream 2369 2371 +2
parse_dollar 730 717 -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 7/-13) Total: -6 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 14:04:57 +02:00
Denys Vlasenko
5b6210cf49
hush: simplification in parse_stream, parse_stream_dquoted
...
function old new delta
parse_stream 2354 2369 +15
parse_stream_dquoted 250 228 -22
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 13:32:21 +02:00
Denys Vlasenko
850b15bfaf
hush: simplify parse_stream_dquoted
...
function old new delta
parse_stream_dquoted 303 250 -53
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 12:58:19 +02:00
Denys Vlasenko
77a7b5519c
hush: straighten out the logic in parse_stream
...
function old new delta
parse_stream 2399 2354 -45
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 12:40:03 +02:00
Dan Fandrich
77d4872691
Avoid side effects in putc(), which may be implemented as a macro
...
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 11:48:02 +02:00
Denys Vlasenko
95d48f2598
hush: eliminate redundant parameter of expand_vars_to_list()
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-08 13:58:55 +02:00
Denys Vlasenko
5b686cb8e6
hush: replace flag bytes in struct o_string with bit flags
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-08 13:44:34 +02:00
Denys Vlasenko
9b78255dca
hush: remove unused enum typedef
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-08 13:33:26 +02:00
Denys Vlasenko
1fd3d94a6c
hush: fix set -- q w e; (IFS='' echo "$*"; IFS=''; echo "$*"); echo "$*"
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-08 13:31:53 +02:00
Denys Vlasenko
8b2f13d84d
shell: unify endofname() in hush and ash
...
function old new delta
builtin_umask 132 133 +1
changepath 195 194 -1
expand_and_evaluate_arith 77 69 -8
ash_arith 143 135 -8
expand_one_var 1551 1515 -36
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 1/-53) Total: -52 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-07 12:19:33 +02:00
Denys Vlasenko
27c56f1267
hush: a few relatively trivial simplifications
...
function old new delta
helper_export_local 130 135 +5
set_vars_and_save_old 89 85 -4
expand_variables 147 141 -6
get_ptr_to_local_var 77 70 -7
get_local_var_value 171 164 -7
delete_finished_bg_job 31 16 -15
hush_exit 101 84 -17
free_pipe_list 31 12 -19
check_and_run_traps 232 205 -27
free_pipe 205 130 -75
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/9 up/down: 5/-177) Total: -172 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-07 09:56:34 +02:00
Denys Vlasenko
da463fb007
hush: style cleanups. no code changes
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-07 09:53:50 +02:00
Denys Vlasenko
605067b426
hush: revert a recent buggy change which resulted in two HUSH_VERSIONs
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 12:10:51 +02:00
Denys Vlasenko
83b900fb82
fix typo in comment
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 11:47:55 +02:00
Denys Vlasenko
c3adfacd22
hush: fix another corner case with backslashes in heredocs
...
function old new delta
parse_stream 2395 2432 +37
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 11:46:03 +02:00
Denys Vlasenko
77b32ccbf2
hush: fix backslash and terminator handling in <<[-]["]heredoc["]
...
function old new delta
parse_stream 2339 2395 +56
expand_pseudo_dquoted 104 118 +14
parse_stream_dquoted 296 300 +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 74/0) Total: 74 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 11:27:32 +02:00
Denys Vlasenko
c49d2d9793
hush: fix globbing+backslashes in unquoted $var expansion
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 10:26:37 +02:00
Denys Vlasenko
d383b49aef
hush: remove disabled CMD_SINGLEWORD_NOGLOB_COND, rename o_glob->perform_glob
...
+ other small tweaks to comments and such
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 10:22:13 +02:00
Denys Vlasenko
96f064d416
shell: remove lash and bbsh
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 10:18:21 +02:00
Denys Vlasenko
b36abf2dfc
hush: big reordering: move parser functions to the beginning. no code changes
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:50:59 +02:00
Denys Vlasenko
38292b68c9
hush: rename o_quoted to has_quoted_part; small code shrink
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:49:40 +02:00
Denys Vlasenko
f2dc20c2d5
hush: move variable expansion into a separate function. No logic changes
...
function old new delta
expand_one_var - 1551 +1551
expand_vars_to_list 2833 1175 -1658
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 1551/-1658) Total: -107 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:48:11 +02:00
Denys Vlasenko
36f774a0cd
hush: add support for ${var/pattern/repl}, conditional on bash compat
...
function old new delta
expand_vars_to_list 2386 2833 +447
expand_string_to_string 69 110 +41
parse_dollar 681 721 +40
hush_main 963 945 -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 528/-18) Total: 510 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:47:58 +02:00
Denys Vlasenko
701e127f7d
hush: optimize #[#] and %[%] for speed. size -2 bytes.
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-04 21:21:07 +02:00
Denys Vlasenko
e298ce69ba
hush: fix handling of backslashes in variable assignment
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-04 19:52:44 +02:00
Denys Vlasenko
8d3e225a2d
libbb: add xfstat function
...
function old new delta
xfstat - 25 +25
mkfs_ext2_main 2421 2423 +2
mkfs_reiser_main 1197 1194 -3
next 312 307 -5
ar_main 533 522 -11
mkfs_minix_main 2938 2924 -14
mkfs_vfat_main 1511 1495 -16
writeTarFile 272 255 -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/6 up/down: 27/-66) Total: -39 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-08-31 12:42:06 +02:00
Denys Vlasenko
0ff78a0166
ash: small code shrink (-21 bytes)
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-08-30 15:20:07 +02:00
Denys Vlasenko
f7a8433535
ash: add another ${v/a/b} test we currently fail
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-08-30 13:54:12 +02:00
Denys Vlasenko
b32a543663
nandwrite: complain on malformed -s NUM
...
Elsewhere: use common error message. -30 bytes net size change
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-29 13:29:02 +02:00
Denys Vlasenko
0ef64bdb40
*: make GNU licensing statement forms more regular
...
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00
Denys Vlasenko
7783248eaa
*: s/xatoi_u/xatoi_positive/g - I got bored of mistyping xatoi_u as xatou_i
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-12 14:14:45 +02:00
Denys Vlasenko
33bbb27e45
ash: fix another bit of var_bash4 bug
...
But it _still_ doesn't pass! quoted case is a tough nut to crack
function old new delta
redirect 1281 1286 +5
subevalvar 1141 1142 +1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-07 22:24:36 +02:00
Denys Vlasenko
09dd6ec732
ash: cosmetic fixes, no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-07 02:44:33 +02:00
Denys Vlasenko
1614900522
ash: fix another bug detected by var_bash4.tests
...
... but var_bash4.tests still does not pass!
function old new delta
expandarg 959 962 +3
localcmd 259 257 -2
readtoken1 3275 3260 -15
subevalvar 1178 1141 -37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 3/-54) Total: -51 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-06 22:06:21 +02:00
Denys Vlasenko
c8d305d89f
var_bash4.tests: better wording in comment
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-06 19:28:04 +02:00
Denys Vlasenko
f02c82f38c
ash: fix dequoting error detected by var_bash4 test
...
But the test still fails (one more bug to fix)
function old new delta
changepath 195 192 -3
readtoken1 3247 3240 -7
subevalvar 1204 1184 -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-30) Total: -30 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-06 19:14:47 +02:00
Denys Vlasenko
f56fe82542
update var_bash4 test. one more bug revealed by it now...
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-06 17:21:52 +02:00
Denys Vlasenko
6814cbc928
ash: extend var_bash4.tests; nocode changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-05 18:29:13 +02:00
Denys Vlasenko
b0fbe4b540
ash: add a testcase for bug 2281 (currently fails). Small code cleanups.
...
function old new delta
changepath 195 192 -3
subevalvar 1204 1200 -4
readtoken1 3247 3240 -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-14) Total: -14 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-05 17:19:27 +02:00
Denys Vlasenko
17662801ec
cttyhack: make it survive WERROR build
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-30 17:41:35 +02:00
Jeremie Koenig
430ba79c39
cttyhack: serial console detection is Linux-specific
...
Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-30 17:40:37 +02:00
Alexander Shishkin
17e0e43c35
ulimit: set both hard and soft limits by default
...
function old new delta
shell_builtin_ulimit 494 498 +4
Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-27 08:40:55 +02:00
Denys Vlasenko
ba2dcccd79
*: trailing empty lines removed
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-26 01:49:12 +02:00
Denys Vlasenko
f3ea792bad
*: mass cosmetic removal of extra empty lines. no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-26 01:06:14 +02:00
Alexander Shishkin
ccb9771861
ash: fix $! value when traps are set
...
Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-25 13:07:39 +02:00
Jeremie Koenig
1d7266d3b5
mark Linux-specific configuration options
...
PLATFORM_LINUX is used as a dependency for applets or features
which require Linux-specific interfaces.
Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-19 00:44:56 +02:00
Denys Vlasenko
6adf2aad38
hush: move msh/lash config into hush.c, no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 19:26:38 +02:00
Denys Vlasenko
51ca7761a3
cttyhack: move build system bits into cttyhack.c, no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 17:16:40 +02:00
Denys Vlasenko
771f1995a9
ash: move config stuff into ash.c, no code chages
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 14:31:34 +02:00
Denys Vlasenko
29082231d0
hush: fix multimple dependent variable expansion cases
...
function old new delta
get_local_var_value 100 171 +71
expand_assignments 46 76 +30
reset_traps_to_defaults 229 238 +9
maybe_set_to_sigexit 47 50 +3
init_sigmasks 211 214 +3
builtin_trap 462 465 +3
expand_vars_to_list 2412 2408 -4
run_pipe 1568 1533 -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/2 up/down: 119/-39) Total: 80 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 13:52:32 +02:00
Denys Vlasenko
202a2d1219
hush: make set -x support optional
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 12:36:14 +02:00
Denys Vlasenko
3f5fae0772
hush: add support for set -x
...
function old new delta
run_pipe 1442 1568 +126
dump_cmd_in_x_mode - 126 +126
builtin_trap 441 462 +21
pseudo_exec_argv 171 187 +16
reset_traps_to_defaults 214 229 +15
check_and_run_traps 227 232 +5
hush_exit 98 101 +3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 6/0 up/down: 312/0) Total: 312 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 12:35:35 +02:00
Denys Vlasenko
b3389de04b
hush: fix typo in comment
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-15 12:33:37 +02:00
Denys Vlasenko
8fa1f5d543
hush: fix faloout from previous commit
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-15 08:18:46 +02:00
Denys Vlasenko
889550b36b
hush: make pun_pipe loop clearer; fix "cmd | var=cmd
| cmd" handling
...
function old new delta
free_strings - 38 +38
pseudo_exec_argv 161 171 +10
free_pipe 227 205 -22
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 48/-22) Total: 26 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-14 19:01:25 +02:00
Denys Vlasenko
9297dbc9d2
randomconfig fixes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-05 21:37:12 +02:00
Pascal Bellard
926031b764
*: introduce and use xfork() and xvfork()
...
function old new delta
launch_helper 170 169 -1
setup_heredoc 312 302 -10
handle_dir_common 367 354 -13
expand_vars_to_list 2456 2443 -13
open_transformer 89 74 -15
data_extract_to_command 439 423 -16
do_ipaddr 1406 1389 -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-85) Total: -85 bytes
Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-04 15:32:38 +02:00
Pascal Bellard
21e8e8da64
libbb: introduce and use BB_EXECVP_or_die()
...
function old new delta
BB_EXECVP_or_die - 47 +47
time_main 1042 1043 +1
chrt_main 371 364 -7
ionice_main 292 282 -10
setsid_main 69 56 -13
nohup_main 236 223 -13
cttyhack_main 266 253 -13
chroot_main 94 81 -13
chpst_main 746 733 -13
timeout_main 297 279 -18
taskset_main 541 522 -19
vfork_child 67 45 -22
parse 975 953 -22
lpd_main 770 748 -22
launch_helper 192 170 -22
tcpudpsvd_main 1810 1782 -28
nice_main 190 156 -34
env_main 242 206 -36
run_command 221 174 -47
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/17 up/down: 48/-352) Total: -304 bytes
Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-04 00:57:03 +02:00
Denys Vlasenko
fd33e17a2b
ash: fix obscure case of replacing + globbing + backslashes
...
function old new delta
subevalvar 1152 1178 +26
readtoken1 3267 3275 +8
redirect 1284 1286 +2
expandarg 957 958 +1
expdir 4 - -4
evalcommand 1219 1209 -10
expmeta 481 469 -12
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 4/2 up/down: 37/-26) Total: 11 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-26 22:55:44 +02:00
Denys Vlasenko
1fcbff2fac
build system: do not rebuild ash and hush on any change to any .c file
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-26 02:40:08 +02:00
Andreas Bühmann
da75f44844
ash: <> redir should not truncate
...
Signed-off-by: Andreas Bühmann <buehmann@users.berlios.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-24 04:32:37 +02:00
Dan Fandrich
fdd7b566ec
A few minor portability improvements
...
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-19 20:03:15 +02:00
Denys Vlasenko
8cd9f343e7
ash: times builtin: use unsigned type; take free-of-charge modulo
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-18 15:36:48 +02:00
Denys Vlasenko
b87c17cd16
*: stop defining _GNU_SOURCE in source files, it's in CFLAGS anyway
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-18 15:15:24 +02:00
Denys Vlasenko
7df28bbb8f
ash: fix unset in standalone mode
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-18 14:23:47 +02:00
Denys Vlasenko
1ed2fb40c9
ash: cosmetics, no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-18 14:09:48 +02:00
Denys Vlasenko
d70e0e995e
*: add INSERTs to *.src files where appropriate
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-08 12:15:11 +02:00
Denys Vlasenko
729ecb87bf
bbconfig: make it independent from printf functions
...
function old new delta
full_write2_str - 25 +25
full_write1_str - 25 +25
clear_main 21 20 -1
telnet_main 1488 1477 -11
getty_main 1932 1918 -14
full_write22_str 25 - -25
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/3 up/down: 50/-51) Total: -1 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-07 14:14:26 +02:00
Denys Vlasenko
121fb9506b
typo fix
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-07 13:34:34 +02:00
Denys Vlasenko
c8aae0b2a0
fix allnoconfig
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-06 22:14:58 +02:00
Denys Vlasenko
161bb8fa12
fix a few goofs uncovered by "make allnoconfig" testing
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-06 05:07:11 +02:00
Denys Vlasenko
2f32bf8be6
remove defconfig. Now "make defconfig" simply uses defaults from Config.in
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-06 04:14:28 +02:00
Denys Vlasenko
da929a95aa
mass renaming Kbuild -> Kbuild.src, Config.in -> Config.src
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-04 20:10:51 +02:00
Denys Vlasenko
79b3d42e13
ash: rename parsefile->fd to ->pf_fd
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-03 04:29:08 +02:00
Denys Vlasenko
08d8b3cee1
ash: fix redirection of fd 0 in scripts are sourced from interactive ash
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-03 04:28:28 +02:00
Denys Vlasenko
ea8b252cb3
*: better string sharing
...
text data bss dec hex filename
849427 441 7556 857424 d1550 busybox_old
849355 441 7556 857352 d1508 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-02 12:57:26 +02:00
Denys Vlasenko
8837c5dec4
ash: remove one redundant function, improve string sharing, better field names
...
function old new delta
var_end - 15 +15
changepath 194 192 -2
setvareq 222 218 -4
lookupvar 57 51 -6
bltinlookup 57 51 -6
evalfun 452 443 -9
varequal 14 - -14
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/5 up/down: 15/-41) Total: -26 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-02 12:56:18 +02:00
Denys Vlasenko
599ae1eb9f
shell: consolidate builtin_foo.? into shell_common.?; delete obsolete shells
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-23 17:49:50 +02:00
Denys Vlasenko
8391c4800c
hush: trivial code shrink
...
function old new delta
static_get 26 22 -4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 17:50:43 +02:00
Denys Vlasenko
2e48d536ce
hush: reduce #ifdef forest a bit, rename handle_dollar -> parse_dollar
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 17:30:39 +02:00
Denys Vlasenko
5ae8f1cdbe
hush: fix hush -c 'echo $0' - was showing empty string
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 06:32:11 +02:00
Denys Vlasenko
e85248afa2
hush: fix segfault in ${?:N:M}
...
function old new delta
expand_vars_to_list 2374 2409 +35
builtin_umask 132 133 +1
builtin_exit 47 48 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 37/0) Total: 37 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 06:20:26 +02:00
Denys Vlasenko
8a33679694
hush: fix "hush -c 'echo $#'" showing -1
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 06:05:02 +02:00
Denys Vlasenko
1e811b1231
hush: support ${var:EXPR:EXPR}!
...
function old new delta
handle_dollar 574 681 +107
expand_and_evaluate_arith - 77 +77
expand_vars_to_list 2302 2374 +72
add_till_closing_bracket 359 368 +9
builtin_exit 48 47 -1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 265/-1) Total: 264 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 03:12:29 +02:00
Denys Vlasenko
ddc62f64ba
hush: fix a nommu todo in recent commits
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 00:53:32 +02:00
Denys Vlasenko
a6ad397ea9
hush: fix more obscure ${var%...} cases
...
function old new delta
add_till_closing_paren 313 359 +46
builtin_exit 48 47 -1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 00:26:06 +02:00
Denys Vlasenko
7436950a75
hush: fix a=abc; c=c; echo ${a%${c}}
...
function old new delta
expand_vars_to_list 2229 2302 +73
add_till_closing_paren 286 313 +27
handle_dollar 623 574 -49
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 100/-49) Total: 51 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 19:52:01 +02:00
Denys Vlasenko
3f78cec347
hush: handle expansions in ${var?expanded_word} constructs
...
function old new delta
expand_vars_to_list 2209 2229 +20
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 17:54:46 +02:00
Denys Vlasenko
349ef96bb5
hush: reorganized TODO comment at top
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 15:46:24 +02:00
Denys Vlasenko
214b8ca3dc
hush: add a list of unsupported builtins
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 15:35:44 +02:00
Denys Vlasenko
73e013fca7
hush: handle ${var:NUM:} too
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 15:24:12 +02:00
Denys Vlasenko
4f2c59b267
hush: remove extra comparison from prev commit
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 01:25:16 +02:00
Denys Vlasenko
4d8e5fdc1d
hush: optional support for ${var:N:M} bashism
...
function old new delta
expand_vars_to_list 1999 2183 +184
handle_dollar 682 623 -59
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-21 01:15:42 +02:00
Denys Vlasenko
53b513331a
hush: explain various parameter expansion ops in comments
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 21:46:45 +02:00
Denys Vlasenko
ee0775dd13
hush: small code shrink
...
function old new delta
expand_vars_to_list 2012 1999 -13
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 16:37:53 +02:00
Denys Vlasenko
e3be7842be
hush: shrink variable expansion code
...
function old new delta
expand_vars_to_list 2164 2012 -152
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 16:27:42 +02:00
Denys Vlasenko
cddbb610cb
hush: fix var=exit 2
not setting $? to 2
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 14:27:09 +02:00
Denys Vlasenko
131ed3bcc9
update shell/README
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 12:56:14 +02:00
Denys Vlasenko
a0ec4f500c
ash: eliminate 16 bytes in bss
...
text data bss dec hexfilename
841423 441 7572 849436 cf61cbusybox_old
841430 441 7556 849427 cf613busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 12:50:42 +02:00
Denys Vlasenko
44c86ce5d7
hush: code shrink
...
text data bss dec hex filename
843121 453 6828 850402 cf9e2 busybox_old
843108 453 6828 850389 cf9d5 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 04:22:55 +02:00
Denys Vlasenko
b131ccec9c
hush: support "cd -- DIR" and such
...
function old new delta
skip_dash_dash - 33 +33
builtin_exit 43 48 +5
builtin_umask 121 125 +4
builtin_shift 115 119 +4
builtin_cd 71 75 +4
builtin_wait 271 274 +3
builtin_source 171 174 +3
builtin_exec 57 60 +3
builtin_eval 46 45 -1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 7/1 up/down: 59/-1) Total: 58 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 03:39:43 +02:00
Denys Vlasenko
40477e2fdb
shell: make it possible to alias one of shells to "bash"
...
function old new delta
packed_usage 27047 27054 +7
applet_names 2227 2232 +5
applet_main 1304 1308 +4
applet_nameofs 652 654 +2
applet_install_loc 163 164 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/0 up/down: 19/0) Total: 19 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-20 02:09:45 +02:00
Denys Vlasenko
42c4b2e3b5
ash: fix var_leak.tests so that it actually catches the NOFORK bug
...
+ document the bug better
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 16:13:56 +02:00
Denys Vlasenko
c7f95d23f6
typo fix
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 15:52:23 +02:00
Denys Vlasenko
238bf187ba
ash: fix bug which causes signal6.tests to fail
...
function old new delta
trapcmd 271 277 +6
localcmd 277 275 -2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 15:49:07 +02:00
Denys Vlasenko
51b4a9e2f1
ash: fix var_leak testcase
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 14:35:20 +02:00
Denys Vlasenko
5e2d572381
ash: fix testsuite false positives
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 14:11:21 +02:00
Denys Vlasenko
e66cf821cf
ash,hush: make bare "." set exitcode to 2
...
function old new delta
dotcmd 300 305 +5
builtin_source 176 171 -5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 09:12:53 +02:00
Denys Vlasenko
0e81e488fd
shell/README: describe special builtins
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 23:51:00 +02:00
Denys Vlasenko
adc0e20892
hush: update bash compat todo comment
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 18:56:58 +02:00
Denys Vlasenko
82731b4b7a
ash,hush: make "source" a synonym for . if bash compat is on
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 17:49:52 +02:00
Denys Vlasenko
cd10dc40e4
ash: fix ". empty_file" exitcode. +5 bytes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 17:10:46 +02:00
Denys Vlasenko
786cce1871
fix false positive in signal5.tests
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 10:14:20 +02:00
Denys Vlasenko
82dd14a510
ash: use CONFIG_FEATURE_EDITING_MAX_LEN
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 10:10:01 +02:00
Denys Vlasenko
ef215558fa
typo fix
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 09:55:13 +02:00
Denys Vlasenko
3227d3f982
hush: fix hush-bugs/parse_err.tests
...
function old new delta
parse_stream 2325 2339 +14
builtin_umask 121 123 +2
builtin_type 116 114 -2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 09:49:47 +02:00
Denys Vlasenko
0f01b00d74
add two more tests which currently fail
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 04:57:55 +02:00
Denys Vlasenko
7c1ed9fbde
ash: fix signal5.tests
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 04:42:40 +02:00
Denys Vlasenko
27ff681cfa
ash: add two testcases for (not yet fixed) ash bugs
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 02:56:18 +02:00
Denys Vlasenko
8806d64acd
hush: mention PPID, RANDOM support
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-16 02:36:18 +02:00
Denys Vlasenko
b367bb2a62
cttyhack: document the need to setsid
...
function old new delta
packed_usage 26988 27057 +69
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-15 20:43:07 +02:00
Denys Vlasenko
5055a9f989
cttyhack: don't do anything if ctty is already available
...
function old new delta
cttyhack_main 244 269 +25
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-14 04:08:20 +02:00
Colin Watson
3963d943f8
ash: refresh stack pointers after makestrspace in rmescapes
...
Without this, rmescapes sometimes returns random garbage while
performing parameter expansions such as ${foo#bar}, in the event that
the allocation of r happens to need to reallocate the stack and hence
invalidate str and p. I'd love to provide a test case but unfortunately
it's dependent on exact stack layout, so I don't have anything simpler
than the situation described in
https://bugs.launchpad.net/ubuntu/+source/partman-base/+bug/527401/comments/23
which involved a sequence of foo="${foo#*, }" expansions on a long
string inside our RAID configuration tool.
The same fix has been in dash since 2007-09-26, contributed by Roy
Marples <uberlord@gentoo.org>. I actually came up with it independently
almost to the character, but then synced it up with the variable naming
used in dash when I noticed that change afterwards.
Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-26 14:21:27 +02:00
Denys Vlasenko
023a08f229
ash: line up builtin table. no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-26 15:53:33 +01:00
Denys Vlasenko
496d5bf4c6
ash: trap with bad signal name should not abort
...
function old new delta
trapcmd 236 271 +35
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-26 15:52:24 +01:00
Denys Vlasenko
651a2697f7
*: merge some common strings
...
text data bss dec hexfilename
838650 8009 0 846659 ceb43busybox_old
838519 8009 0 846528 ceac0busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-23 16:25:17 +01:00
Denys Vlasenko
1497484839
ash,hush: make it possible to build them individually
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-23 01:08:26 +01:00
Denys Vlasenko
b76356b28e
ash: fix quadratic matching slowdown is ${v/*foo*/repl} (really bad one)
...
It is especially bad with patterns starting with "*".
With ASH_OPTIMIZE_FOR_SIZE=y, only those are optimized, +few bytes:
text data bss dec hex filename
836337 441 7564 844342 ce236 busybox_old
836341 441 7564 844346 ce23a busybox_unstripped
With ASH_OPTIMIZE_FOR_SIZE off, we also optimize patterns _ending_ with "*",
which costs about 80 bytes:
text data bss dec hex filename
836656 441 7564 844661 ce375 busybox_old
836732 441 7564 844737 ce3c1 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-13 16:19:04 +01:00
Denys Vlasenko
f15620c377
shell/ulimit: code shrink by 10 bytes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-08 23:28:30 +01:00
Denys Vlasenko
f3c742f925
hush: use ash's ulimit builtin; make it more more bash0like while at it
...
Based on a patch by Tobias Klauser <tklauser@distanz.ch>
function old new delta
shell_builtin_ulimit - 498 +498
limits_tbl 33 88 +55
ulimit_opt_string - 38 +38
bltins1 288 300 +12
limits_name 127 - -127
ulimitcmd 415 7 -408
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 2/1 up/down: 603/-535) Total: 68 bytes
text data bss dec hex filename
839229 453 6828 846510 ceaae busybox_old
839423 453 6828 846704 ceb70 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-06 20:12:00 +01:00
Denys Vlasenko
4b1100edd8
*: use NULL for null pointers
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-05 14:10:54 +01:00
Denys Vlasenko
153fcaa6c1
Replace __uClinux__ define with !BB_MMU
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-02-21 05:17:41 +01:00
Denys Vlasenko
7426920461
fix bug 1087. Fix by Leonid (lly.dev AT gmail.com)
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-02-21 01:26:42 +01:00
Denys Vlasenko
14a917eaab
hush: note a FIXME
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-02-08 03:04:22 +01:00
Denys Vlasenko
083e172641
style fixes, no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-28 12:30:24 +01:00
Denys Vlasenko
6b9f163353
*: style fixes. no code changes (verified with objdump)
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-28 02:24:24 +01:00
Denys Vlasenko
17323a6245
hush: more "greppable" field names. no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-28 01:57:05 +01:00
Denys Vlasenko
3581c62515
whitespace fixes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-25 13:39:24 +01:00
Denys Vlasenko
6b01b71e83
randomconfig fixes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-24 22:52:21 +01:00
Denys Vlasenko
85d286efc8
ash: remove config items for read options which are no longer optional
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-13 18:31:29 +01:00
Denys Vlasenko
25d9b91d94
shell/read: check that variable names are sane
...
function old new delta
shell_builtin_read 1000 1055 +55
parse_command 1460 1463 +3
builtin_umask 121 123 +2
is_well_formed_var_name 73 66 -7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-13 18:22:35 +01:00
Denys Vlasenko
03d81ef43a
builtin_read: note about better implementation
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-13 14:53:49 +01:00
Denys Vlasenko
03dad22f8a
hush: use ash's read builtin
...
function old new delta
shell_builtin_read - 1000 +1000
set_local_var_from_halves - 24 +24
setvar2 - 7 +7
...
popstring 140 134 -6
ash_main 1375 1368 -7
setvar 184 174 -10
arith_set_local_var 36 - -36
builtin_read 1096 185 -911
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 5/23 up/down: 1038/-1007) Total: 31 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 23:29:57 +01:00
Denys Vlasenko
045f4ad92c
shell/read: fix "'read' without parameters" bash compat thingy
...
previous change:
function old new delta
builtin_read 82 1074 +992
popstring 134 140 +6
readcmd 1034 148 -886
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 998/-886) Total: 112 bytes
this change:
builtin_read 1074 1096 +22
static.arg_REPLY 8 - -8
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 22/-8) Total: 14 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 22:12:10 +01:00
Denys Vlasenko
7306727d1b
shell: split read builtin from ash
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 22:11:24 +01:00
Denys Vlasenko
6c93b24ce9
hush: fix potential buffer overflow on NOMMU
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 19:28:10 +01:00
Denys Vlasenko
e89a241b9e
hush: fix subshell.tests failure on NOMMU
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 15:19:31 +01:00
Denys Vlasenko
b70cef71eb
hush: two NOMMU fixes for bugs 877 and 883
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 13:45:45 +01:00
Denys Vlasenko
f2c8aa6676
libbb: introduce and use monotonic_ms
...
function old new delta
monotonic_ms - 60 +60
process_stdin 433 443 +10
display_speed 85 90 +5
nmeter_main 672 674 +2
builtin_type 114 116 +2
bb__parsespent 117 119 +2
ifplugd_main 1110 1109 -1
acpid_main 441 440 -1
chat_main 1361 1359 -2
doCommands 2458 2449 -9
arpping 466 450 -16
run_command 268 234 -34
readcmd 1072 1034 -38
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/7 up/down: 81/-101) Total: -20 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 12:52:30 +01:00
Denys Vlasenko
385cc59117
hush: plug a memory leak
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12 06:47:39 +01:00
Denys Vlasenko
8cd04d1cb6
ash: fix for read $IFS splitting. Closes bug 235
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-08 15:44:07 +01:00
Chris Metcalf
c3c1fb676b
ash: fix mishandling of bash-style redirects
...
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-08 13:18:06 +01:00
Denys Vlasenko
2ec91aead5
*: remove some uses of argc
...
function old new delta
whoami_main 34 37 +3
logname_main 60 63 +3
hostid_main 35 38 +3
ttysize_main 136 135 -1
nmeter_main 673 672 -1
logger_main 387 386 -1
uuencode_main 330 328 -2
ifupdown_main 2125 2123 -2
mesg_main 158 155 -3
free_main 333 330 -3
cal_main 902 899 -3
acpid_main 443 440 -3
ar_main 196 189 -7
find_main 476 467 -9
ifconfig_main 1235 1221 -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/12 up/down: 9/-49) Total: -40 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-04 14:15:38 +01:00
Denys Vlasenko
a4899efd03
hush: fix exitcodes of killed processes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-04 11:37:09 +01:00
Denys Vlasenko
46a1477107
ash: trivial optimization -6 bytes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-12-10 21:27:13 +01:00
Denys Vlasenko
e9ac32a067
ash: fix double comma in initializer
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-12-05 02:01:25 +01:00
Michael Abbott
359da5e3be
ash: implement set -o pipefail (conditional on bash compat). +39 bytes
...
Signed-off-by: Michael Abbott <michael@araneidae.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-12-04 23:03:29 +01:00
Denys Vlasenko
285ad155c4
ash: preparatory work for pipefail and code shrink. -44 bytes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-12-04 23:02:27 +01:00
Denys Vlasenko
7a7b034482
ash: re-enable SIGHUP on entry. Closes bug 771.
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-12-04 04:18:31 +01:00
Denys Vlasenko
8eda4a9005
ash: straighten up a bit of code in varvalue()
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-30 12:16:17 +01:00
Denys Vlasenko
2ce42e98d7
ash: more cosmetics and cleanups
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-29 02:18:13 +01:00
Denys Vlasenko
068d386a6c
ash: cosmetics, no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-29 01:41:11 +01:00
Denys Vlasenko
76bc2d6deb
ash: remove last "signed char"; make SIT() clearer. -12 bytes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-29 01:37:46 +01:00
Denys Vlasenko
0337e038a9
ash: randmconfig fix
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-29 00:12:30 +01:00
Denys Vlasenko
cd71683ae6
ash: remake strange signed char machinery to be unsigned. -57 bytes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-28 22:14:02 +01:00
Denys Vlasenko
160b9ca731
ntpd: make it NOMMU-safe; ash: exclude it on NOMMU builds
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-27 02:35:15 +01:00
Denys Vlasenko
c270454f8f
fix fallout from isprint() changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-20 19:14:19 +01:00
Denys Vlasenko
f3e2818895
hush: improve HUSH_BRACE_EXP code (still disabled). ~0 bytes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-17 03:35:31 +01:00
Denys Vlasenko
160746b603
tweak in comment
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-16 05:51:18 +01:00
Denys Vlasenko
5b2db97703
hush: initial stab at brace expansion support
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-16 05:49:36 +01:00
Denys Vlasenko
d8389ad760
hush: fix handling of words with braces. +65 bytes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-16 03:18:46 +01:00
Denys Vlasenko
00243b0a1a
hush: fix exit code propagation from cmd
. +45 bytes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-16 02:00:03 +01:00
Denys Vlasenko
a7ccdeef39
libbb: added xfdopen_for_read/write
...
function old new delta
xfdopen_helper - 40 +40
logdir_open 1163 1184 +21
process_stdin 433 443 +10
xfdopen_for_write - 9 +9
doCommands 2465 2474 +9
patch_main 1214 1222 +8
bbunpack 457 465 +8
xfdopen_for_read - 7 +7
scan_tree 258 262 +4
xstrtoul_range_sfx 230 231 +1
sendmail_main 957 955 -2
passwd_main 1027 1023 -4
parse 969 964 -5
test_main 253 247 -6
sed_main 655 649 -6
dos2unix_main 437 429 -8
fbsplash_main 950 938 -12
handle_dir_common 371 354 -17
expand_vars_to_list 2197 2169 -28
update_passwd 1275 1246 -29
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 7/10 up/down: 117/-117) Total: 0 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-15 23:28:11 +01:00
Denys Vlasenko
647553a4fc
hush: wait for cmd
to complete, and immediately store its exitcode in $?
...
function old new delta
expand_vars_to_list 2129 2197 +68
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-15 19:58:19 +01:00
Denys Vlasenko
0d8c0b810e
removed SuSv3 doc tarball - potential licensing problem
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-06 04:11:22 +01:00
Denys Vlasenko
8131eea3dc
*: introduce and use ffulsh_all()
...
function old new delta
buffer_fill_and_print 179 196 +17
fflush_all - 9 +9
spawn 87 92 +5
rtcwake_main 455 453 -2
...
alarm_intr 93 84 -9
readcmd 1072 1062 -10
bb_ask 345 333 -12
more_main 845 832 -13
flush_stdout_stderr 42 23 -19
xfflush_stdout 27 - -27
flush_stderr 30 - -30
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/50 up/down: 31/-397) Total: -366 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-02 14:19:51 +01:00
Denys Vlasenko
f2cbb03a37
*: optimize most of isXXXXX() macros
...
text data bss dec hex filename
824164 453 6812 831429 cafc5 busybox_old
823730 453 6812 830995 cae13 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-23 03:16:08 +02:00
Denys Vlasenko
c1947f18f5
build failure fix and some cosmetics
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-23 01:30:26 +02:00
Denys Vlasenko
c0dab37d0a
*: remove last function calls to isspace
...
function old new delta
xstrtoul_range_sfx 232 231 -1
xstrtoull_range_sfx 295 293 -2
trim 82 80 -2
trim_trailing_spaces_and_print 57 52 -5
isspace 18 - -18
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-22 22:28:08 +02:00
Denys Vlasenko
3ef4f77620
hush: fix exec builtin in a better way (+ "glob in exec" bug fixed)
...
function old new delta
execvp_or_die - 50 +50
static.pseudo_null_str 3 - -3
builtin_exec 83 57 -26
pseudo_exec_argv 200 163 -37
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 50/-66) Total: -16 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-19 23:09:06 +02:00
Denys Vlasenko
aaa22d2493
hush: use configured max line length, not BUFSIZE from libc
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-19 16:34:39 +02:00
Denys Vlasenko
36df04837a
randomconfig fixes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-19 16:07:28 +02:00
Denys Vlasenko
3b3ccdc5bc
hush: remove superfluous assignment
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-19 13:24:07 +02:00
Denys Vlasenko
8bc7f2c5aa
hush: make it compile again :/
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-19 13:20:52 +02:00
Denys Vlasenko
c0836530f1
hush: cosmetics. no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-19 13:13:06 +02:00
Denys Vlasenko
f37eb3999b
hush: fix handling of empty arguments
...
function old new delta
builtin_exec 25 83 +58
parse_stream 2242 2261 +19
run_pipe 1782 1787 +5
static.pseudo_null_str - 3 +3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 85/0) Total: 85 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-18 11:46:35 +02:00
Mike Frysinger
28736c36ca
hush: handle empty execs
...
Sometimes variable expansions yield empty strings, and if they happen to
be a command someone wants to run like `$foo`, then hush currently
segfaults. So handle `` and $().
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-10-18 01:15:36 -04:00
Mike Frysinger
4ebc76c8a2
hush: add a printf builtin
...
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-10-15 03:33:31 -04:00
Mike Frysinger
ccb1959aa5
hush: unify handling of builtin applets
...
Saves about 10 bytes for each additional builtin applet.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-10-15 03:33:31 -04:00
Denys Vlasenko
76ace254e1
ash,hush: fix $RANDOM in children being repeated
...
function old new delta
next_random 46 68 +22
forkshell 248 263 +15
expand_vars_to_list 2118 2131 +13
run_pipe 1775 1782 +7
popstring 134 140 +6
builtin_umask 123 121 -2
ash_main 1356 1336 -20
get_local_var_value 125 104 -21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/3 up/down: 63/-43) Total: 20 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-12 15:25:01 +02:00
Denys Vlasenko
8c66a9d07a
hush: shrink $RANDOM support
...
function old new delta
get_local_var_value 104 125 +21
hush_main 1024 983 -41
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-11 02:15:49 +02:00
Denys Vlasenko
e7670ff81d
ash: use bbox wrappers for malloc etc instead of homegrown ones
...
function old new delta
popstring 134 140 +6
ckmalloc 9 - -9
ckstrdup 22 - -22
ckrealloc 24 - -24
ckzalloc 28 - -28
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 1/0 up/down: 6/-83) Total: -77 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-11 00:45:25 +02:00
Denys Vlasenko
0e5e4eaf7b
ash: trivial shrink by using smaller int
...
function old new delta
copynode 197 196 -1
calcsize 127 126 -1
nodesize 54 27 -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-29) Total: -29 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-11 00:36:20 +02:00
Denys Vlasenko
e3c6e19015
laguage and copyright date corrections, no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 23:35:30 +02:00
Denys Vlasenko
3dc4a3e4dc
ash: make one testsuite entry more robust
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 23:08:28 +02:00
Denys Vlasenko
69d1f45c16
shell/Config.in: forgotten chunk with CONFIG_HUSH_RANDOM_SUPPORT
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 22:11:30 +02:00
Denys Vlasenko
cbe0b7fb59
hush: fix cut-n-paste error in last commit
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 22:00:58 +02:00
Denys Vlasenko
20b3d144e9
hush: add support for $RANDOM. If on:
...
function old new delta
hush_main 983 1024 +41
get_local_var_value 72 104 +32
block_signals 155 161 +6
reset_traps_to_defaults 211 214 +3
builtin_wait 268 271 +3
pseudo_exec_argv 198 200 +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 87/0) Total: 87 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 20:59:39 +02:00
Denys Vlasenko
3ea2e82dc7
ash: factor out $RANDOM support
...
function old new delta
next_random - 46 +46
ash_main 1361 1356 -5
change_random 132 97 -35
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 46/-40) Total: 6 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 20:59:04 +02:00
Denys Vlasenko
dea478855f
hush: support $PPID
...
function old new delta
get_local_var_value 33 72 +39
hush_main 951 983 +32
block_signals 152 155 +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 74/0) Total: 74 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-09 15:40:49 +02:00
Denys Vlasenko
adf922ec28
*: a few more NOINLINEs
...
function old new delta
print_linkinfo - 815 +815
do_msg - 783 +783
INET_setroute - 757 +757
varvalue - 746 +746
do_sem - 637 +637
inflate_codes - 617 +617
INET6_setroute - 491 +491
edir - 370 +370
sync_cursor - 298 +298
update_utmp - 246 +246
searchLines - 165 +165
setup_alarm - 144 +144
may_wakeup - 101 +101
getNum 566 371 -195
refresh 1166 848 -318
rtcwake_main 809 479 -330
getty_main 2396 1921 -475
chpst_main 1373 746 -627
inflate_unzip_internal 1335 567 -768
evalvar 1384 612 -772
ipaddr_list_or_flush 2160 1246 -914
route_main 1585 245 -1340
ipcs_main 2523 1049 -1474
------------------------------------------------------------------------------
(add/remove: 13/0 grow/shrink: 0/10 up/down: 6170/-7213) Total: -1043 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-08 14:35:37 +02:00
Denys Vlasenko
a7bb3c1396
*: code shrink via NOINLINE
...
function old new delta
expand_vars_to_list - 2118 +2118
lzo1x_optimize - 1429 +1429
run_pipe 358 1775 +1417
arith_apply - 1335 +1335
mainQSort3 - 1198 +1198
logdir_open - 1163 +1163
rewrite - 1039 +1039
dump_identity - 987 +987
do_shm - 884 +884
cpio_o - 863 +863
cpio_main 1450 560 -890
ipcs_main 3442 2523 -919
bb_dump_dump 2611 1488 -1123
process_dev 4572 3405 -1167
logdirs_reopen 1308 86 -1222
arith 2084 707 -1377
mainSort 2622 1202 -1420
do_lzo_compress 2276 799 -1477
run_list 2491 943 -1548
expand_variables 2280 135 -2145
------------------------------------------------------------------------------
(add/remove: 9/0 grow/shrink: 1/10 up/down: 12433/-13288) Total: -855 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-08 12:28:08 +02:00
Denys Vlasenko
57ce977a97
ash: compile breakage fix
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-08 04:19:14 +02:00
Denys Vlasenko
d427689eee
Fix english in build system
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-06 22:13:37 +02:00
Denys Vlasenko
7bb346f23c
*: use {i,u}toa() where appropriate
...
function old new delta
startservice 377 363 -14
setari_u 54 40 -14
ash_main 1375 1361 -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-42) Total: -42 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-06 22:09:50 +02:00
Cristian Ionescu-Idbohrn
301f5ecb8d
ash: error out on ${#1#}, ${#$11}, ${#11#}
...
Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-05 02:07:23 +02:00
Denys Vlasenko
4d8873f997
ash: document where we accept invalid syntax. no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-04 03:14:41 +02:00
Denys Vlasenko
76622dbd16
ash: code shrink
...
function old new delta
ulimitcmd 489 415 -74
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-04 01:14:19 +02:00
Denys Vlasenko
3a7034c27b
typo fix in a comment in a testcase. oh well...
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-30 02:48:59 +02:00
Denys Vlasenko
c34c033c42
ash,hush: share string
...
function old new delta
optschanged 133 139 +6
hush_main 997 982 -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 6/-15) Total: -9 bytes
text data bss dec hexfilename
823160 445 7668 831273 caf29busybox_old
823102 445 7668 831215 caeefbusybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-29 12:25:30 +02:00
Denys Vlasenko
db9c57eed1
libbb/lineedit: fix the case when we configured history to have 0 lines
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-27 02:48:53 +02:00
Denys Vlasenko
e74aaf9385
ash,hush: make trap output short signal names, without SIG prefix
...
function old new delta
evalvar 1373 1371 -2
builtin_trap 457 441 -16
trapcmd 260 236 -24
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-27 02:05:45 +02:00
Denys Vlasenko
67f7186403
hush: do not reset to default "" traps in subshell
...
function old new delta
reset_traps_to_defaults 164 211 +47
builtin_umask 123 121 -2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-25 14:21:06 +02:00
Denys Vlasenko
4ea0ca8193
hush: document a TODO. no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-25 12:58:37 +02:00
Denys Vlasenko
8f88d85e34
ash: better comment. no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-25 12:12:53 +02:00
Denys Vlasenko
726e1a04f7
ash: even smaller trap
code
...
function old new delta
evalvar 1371 1373 +2
trapcmd 347 260 -87
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-25 02:58:20 +02:00
Denys Vlasenko
e305c28285
ash: slightly better (more correct) code for "trap hack"
...
function old new delta
changepath 194 195 +1
evalvar 1373 1371 -2
forkchild 602 590 -12
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-25 02:12:27 +02:00
Denys Vlasenko
21d87d495a
ash: better handling of EXIT trap in trap
hack
...
function old new delta
forkchild - 602 +602
trapcmd 255 347 +92
ash_main 1362 1375 +13
evalvar 1371 1373 +2
popstring 140 134 -6
forkshell 835 248 -587
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/2 up/down: 709/-593) Total: 116 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-25 00:06:51 +02:00
Denys Vlasenko
0800e3af75
ash: do not let EXIT trap to fire in trap
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-24 03:09:26 +02:00
Denys Vlasenko
7188540257
hush: small speed optimization. +10 bytes.
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-24 01:44:13 +02:00
Denys Vlasenko
2f7894b1bb
ash,hush: fix trap reporting: s/SIGEXIT/EXIT/
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-24 01:43:21 +02:00
Denys Vlasenko
606291beab
*: more portability fixes by Dan Fandrich
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-23 23:15:43 +02:00
Denys Vlasenko
1f27ab0d4b
*: optimize code size in strtoul calls
...
function old new delta
bb_parse_mode 433 431 -2
rtnl_rtntype_a2n 202 198 -4
ParseField 511 498 -13
bb_init_module_24 4730 4675 -55
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-74) Total: -74 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-23 17:17:53 +02:00
Denys Vlasenko
844f990926
ash: fix trap
...
function old new delta
forkshell 738 810 +72
popstring 134 140 +6
parse_command 1460 1463 +3
evalvar 1373 1371 -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 81/-2) Total: 79 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-23 03:25:52 +02:00