aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2016-10-03hush: fix a memory corruption when exported variable is modifiedDenys Vlasenko
The construct such as this: t=1 export t t=new_value1 had a small probability of momentarily using free()d value. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03hush: fix exitcode on exec failure with EACCES - should be 126Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03sh testsuite: add tests for exitcode on failure to execDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03shell: delete all msh testsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03hush testsuite: fix another false positiveDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03hust testsuite: fix a false positiveDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03ash testsuite: add most of hust tests which pass for ashDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02ash: [PARSER] Add nlprompt/nlnoprompt helpersDenys Vlasenko
Upstream commit: Date: Mon, 29 Sep 2014 22:53:53 +0800 [PARSER] Add nlprompt/nlnoprompt helpers This patch adds the nlprompt/nlnoprompt helpers to isolate code dealing with newlines and prompting. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02whitespace fixesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02hush: add var4.tests, var5.testsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02hush: fix var3.testsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02sh: do not print empty line at the end of "help" outputDenys Vlasenko
It's pointless. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02sh testsuite: sync ash-redir/ and hush-redir/Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02sh testsuite: sync ash-misc/source* and hush-misc/source*Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02sh testsuite: sync ash-vars/ and hush-vars/Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02ash testsuite: update some of variable tests with newer versions from hushDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02sh testsuite: create hush-redir/* and move files aroundDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02sh testsuite: create hush-heredoc/* and move files aroundDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02hush testsuite: add many tests from ash testsuiteDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02ash: undo "tokname hack"Denys Vlasenko
dash has tokendlist[] array to decide which tokens end lists. We store it as first byte of each tokname_array[i]. Switch to bit array, name it like dash (tokendlist), drop special 1st byte of tokname_array[i]. This brings us closer to dash, and shrinks the binary, because many more string aliasing opportunities are now open: function old new delta pstrcmp1 - 16 +16 readtoken1 2852 2858 +6 list 326 327 +1 pstrcmp 16 15 -1 tokname 45 42 -3 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/2 up/down: 23/-4) Total: 19 bytes text data bss dec hex filename 943556 916 14292 958764 ea12c busybox_old 943463 916 14292 958671 ea0cf busybox_unstripped ^^^^^^^ note this! Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02ash: placate gcc: "warning: ! is only applied to the left hand side of =="Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02hush testsuite: add glob_dir.testsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02ash: fix globbing bugs when using glibc glob()Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02ash: style fixesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02ash: support "--" in "source" builtinDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02ash: expand: Fixed "$@" expansion when EXP_FULL is falseDenys Vlasenko
Upstream commit: Date: Thu, 1 Jan 2015 07:53:10 +1100 expand: Fixed "$@" expansion when EXP_FULL is false The commit 3c06acdac0b1ba0e0acdda513a57ee6e31385dce ([EXPAND] Split unquoted $@/$* correctly when IFS is set but empty) broke the case where $@ is in quotes and EXP_FULL is false. In that case we should still emit IFS as field splitting is not performed. Reported-by: Juergen Daubert <jue@jue.li> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02test: fix compile error in last commitDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-02test: memory leak: free group id listDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01ash,hush: add a test that "continue" does not cripple trapsDenys Vlasenko
Both shells pass this test. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01ash: fix return_in_trap1.tests failureDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01ash testsuite: add return_in_trap1.testsDenys Vlasenko
Currently it fails Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01hush: 'return' should have effect earlierDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01ash: [EXPAND] Optimise nulonly away and just use quoted as beforeDenys Vlasenko
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-01ash: [EXPAND] Do not split quoted VSLENGTH and VSTRIMDenys Vlasenko
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-01ash: [EXPAND] Split unquoted $@/$* correctly when IFS is set but emptyDenys Vlasenko
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-01hush: add func6.testsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01ash: fix "return N" not setting $? in loop conditionalsDenys Vlasenko
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-01ash testsuite: remove two more inadvertent bashismsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01ash testsuite: remove two inadvertent bashismsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01ash: [ERROR] Set exitstatus in onintDenys Vlasenko
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-01ash: [EVAL] Revert SKIPEVAL into EXEXITDenys Vlasenko
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-01ash: [EVAL] Pass EV_TESTED into evalcmdDenys Vlasenko
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-01ash: fix a thinko in the last commitDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01ash: make internal globbing code selectable from configDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-01ash: explain how "command" is handled, and shrink it a bitDenys Vlasenko
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-09-30ash: [VAR] Initialise OPTIND after importing environmentDenys Vlasenko
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-30ash: [BUILTIN] Merge SKIPFUNC/SKIPFILE and only clear SKIPFUNC when leaving ↵Denys Vlasenko
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-30hush: enable "msh is deprecated" message in msh stubDenys Vlasenko
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-30ash: Avoid overflow for very long variable nameDenys Vlasenko
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-30ash: [VAR] Sanitise environment variable names on entryDenys Vlasenko
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>