aboutsummaryrefslogtreecommitdiff
path: root/shell (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
| * ash: [EVAL] Let funcnode refer to a function definition, not its first commandDenys Vlasenko2016-10-251-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream patch: Date: Tue, 15 Mar 2011 15:44:47 +0800 [EVAL] Let funcnode refer to a function definition, not its first command It is not unrelated: I changed the meaning of struct funcnode's field n to refer to the function definition, rather than the list of the function's commands, because I needed to refer to the function definition node from evalfun, which only gets passed a funcnode. But it is something that could be applied independently (without being useful by itself), so I've attached it as a separate patch for easier review. Signed-off-by: Harald van Dijk <harald@gigawatt.nl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [REDIR] Remove EMFILE special caseDenys Vlasenko2016-10-251-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Sun, 6 May 2007 12:01:37 +1000 [REDIR] Remove EMFILE special case No caller of copyfd need to ignore EMFILE so we can remove the special case and just let it call sh_error on any error. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [EVAL] Check exit for eval NSUBSHELLDenys Vlasenko2016-10-251-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Tue, 6 Jul 2010 17:50:37 +0800 [PATCH 161/277] [EVAL] Check exit for eval NSUBSHELL Example: $ dash -c 'set -e; (false); echo here' here With this commit, dash exits 1 before echo. The bug was reported by Stefan Fritsch through http://bugs.debian.org/514863 Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> This was fixed differently in our tree: Date: Fri Sep 16 19:04:02 2016 +0000 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> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: add comment explaining "set -e; $(cmd)" discrepancyDenys Vlasenko2016-10-251-0/+8
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: reduce code differences from upstreamDenys Vlasenko2016-10-251-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Wed, 8 Sep 2010 16:21:52 +0800 [JOBS] Debug compile fix No point in tracing a no longer undeclared "ps->cmd", fixes: jobs.c: In function \u2018commandtext\u2019: jobs.c:1192: error: \u2018ps\u2019 undeclared (first use in this function) jobs.c:1192: error: (Each undeclared identifier is reported only once jobs.c:1192: error: for each function it appears in.) Signed-off-by: maximilian attems <max@stro.at> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: remove unused EXSHELLPROCDenys Vlasenko2016-10-251-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Sun, 28 Nov 2010 20:47:07 +0800 [BUILTIN] Stop documenting EXSHELLPROC At some point between ash 0.3.5-11.0.1 and ash 0.3.8-37, Debian ash stopped using the EXSHELLPROC exception to handle shell scripts without a magic number. Remove all remaining references to it to avoid confusion. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [BUILTIN] Use EXEXIT in place of EXEXECDenys Vlasenko2016-10-251-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Sun, 28 Nov 2010 20:44:37 +0800 [BUILTIN] Use EXEXIT in place of EXEXEC The intended semantics of EXEXEC are identical to EXEXIT, so simplify by using EXEXIT directly. Functional change: in edge cases (exec within a trap handler), this causes the exit status from exec not to be clobbered. For example, without this patch: $ sh -c 'trap "exec nonexistent" EXIT'; echo $? exec: 1: nonexistent: not found 0 And with it: $ sh -c 'trap "exec nonexistent" EXIT'; echo $? exec: 1: nonexistent: not found 127 Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash,hush: set exit code 127 in "sh /does/not/exist" caseDenys Vlasenko2016-10-252-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit 1 for ash: [ERROR] Allow the originator of EXERROR to set the exit status Some errors have exit status values specified by POSIX and it is therefore desirable to be able to set the exit status at the EXERROR source rather than in main.c. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Upstream commit 2 for ash: [INPUT] Use exit status 127 when the script to run does not exist This commit makes dash exit with return code 127 instead of 2 if started as non-interactive shell with a non-existent command_file specified as argument (or a directory), as documented in http://www.opengroup.org/onlinepubs/009695399/utilities/sh.html#tag_04_128_14 The wrong exit code was reported by Clint Adams and Jari Aalto through http://bugs.debian.org/548743 http://bugs.debian.org/548687 Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> NB: in fact, http://bugs.debian.org/548687 was not fixed by this: "sh /dir/" thinks that EISDIR error on read is EOF, and exits 0. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: explain EXP_REDIR and why we (dont) glob redir filenamesDenys Vlasenko2016-10-241-0/+11
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: return exit status of nofork appletsRon Yorston2016-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | The commit 'ash: eval: Return status in eval functions' changed how exit status is handled in eval functions. The case of nofork applets was missed, resulting in the incorrect status potentially being returned for nofork applets when FEATURE_SH_NOFORK is enabled. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: all blocks in function node copying must be SHELL_ALIGNedDenys Vlasenko2016-10-071-3/+3
| | | | | | | | | | | | | | | | | | | | Previous commit probably introduced a bug: non-matching size calculation in size counting and actual copying caused by SHELL_ALIGN being applied differently! This won't bite if string sizes are also SHELL_ALIGNed. Thus fixing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Post-merge fixesRon Yorston2016-10-201-3/+3
| | | | | | | | | | Update default configurations; rename ststrdup -> sstrdup; fix status returns in evalcommand.
* | Merge "ash testsuite: fix false positives"Ron Yorston2016-10-192-2/+2
|\|
| * ash testsuite: fix false positivesDenys Vlasenko2016-10-072-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: get rid of two global data variablesDenys Vlasenko2016-10-071-51/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta calcsize 126 147 +21 funcstring_end - 4 +4 sizenodelist 28 24 -4 funcstringsize 4 - -4 funcstring 4 - -4 funcblocksize 4 - -4 nodeckstrdup 48 39 -9 evaltree 828 788 -40 ------------------------------------------------------------------------------ (add/remove: 1/3 grow/shrink: 1/4 up/down: 25/-105) Total: -40 bytes text data bss dec hex filename 943376 916 14292 958584 ea078 busybox_old 943344 916 14284 958544 ea050 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch busybox (up to "ash: comment out free(p) just before...")Ron Yorston2016-10-19358-1183/+3823
|\|
| * ash: comment out free(p) just before _exit, tweak some outdated commentsDenys Vlasenko2016-10-071-16/+5
| | | | | | | | | | | | Planned to sync exitshell up to dash, turned out ours is better :) Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: add commented-out debug printouts in "memleak" built-inDenys Vlasenko2016-10-031-0/+9
| | | | | | | | | | | | | | Allocation addresses of malloc() are jittery, thought I had a mem leak in hush, but it was malloc variability. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix a memory corruption when exported variable is modifiedDenys Vlasenko2016-10-031-7/+19
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * hush: fix exitcode on exec failure with EACCES - should be 126Denys Vlasenko2016-10-031-1/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sh testsuite: add tests for exitcode on failure to execDenys Vlasenko2016-10-038-0/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: delete all msh testsDenys Vlasenko2016-10-0347-356/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush testsuite: fix another false positiveDenys Vlasenko2016-10-032-2/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hust testsuite: fix a false positiveDenys Vlasenko2016-10-031-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash testsuite: add most of hust tests which pass for ashDenys Vlasenko2016-10-03103-0/+795
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [PARSER] Add nlprompt/nlnoprompt helpersDenys Vlasenko2016-10-021-19/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * whitespace fixesDenys Vlasenko2016-10-022-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: add var4.tests, var5.testsDenys Vlasenko2016-10-024-0/+22
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix var3.testsDenys Vlasenko2016-10-024-206/+214
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sh: do not print empty line at the end of "help" outputDenys Vlasenko2016-10-022-2/+1
| | | | | | | | | | | | It's pointless. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sh testsuite: sync ash-redir/ and hush-redir/Denys Vlasenko2016-10-0218-114/+313
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sh testsuite: sync ash-misc/source* and hush-misc/source*Denys Vlasenko2016-10-0210-27/+50
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sh testsuite: sync ash-vars/ and hush-vars/Denys Vlasenko2016-10-0211-20/+39
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash testsuite: update some of variable tests with newer versions from hushDenys Vlasenko2016-10-026-25/+156
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sh testsuite: create hush-redir/* and move files aroundDenys Vlasenko2016-10-0230-0/+143
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sh testsuite: create hush-heredoc/* and move files aroundDenys Vlasenko2016-10-0216-0/+30
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush testsuite: add many tests from ash testsuiteDenys Vlasenko2016-10-0234-3/+254
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: undo "tokname hack"Denys Vlasenko2016-10-021-41/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: placate gcc: "warning: ! is only applied to the left hand side of =="Denys Vlasenko2016-10-021-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush testsuite: add glob_dir.testsDenys Vlasenko2016-10-023-1/+45
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: fix globbing bugs when using glibc glob()Denys Vlasenko2016-10-023-7/+66
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: style fixesDenys Vlasenko2016-10-021-8/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: support "--" in "source" builtinDenys Vlasenko2016-10-021-12/+18
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: expand: Fixed "$@" expansion when EXP_FULL is falseDenys Vlasenko2016-10-025-15/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * test: memory leak: free group id listDenys Vlasenko2016-10-021-7/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash,hush: add a test that "continue" does not cripple trapsDenys Vlasenko2016-10-014-0/+16
| | | | | | | | | | | | Both shells pass this test. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: fix return_in_trap1.tests failureDenys Vlasenko2016-10-011-23/+28
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash testsuite: add return_in_trap1.testsDenys Vlasenko2016-10-0122-0/+22
| | | | | | | | | | | | Currently it fails Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: 'return' should have effect earlierDenys Vlasenko2016-10-013-14/+42
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [EXPAND] Optimise nulonly away and just use quoted as beforeDenys Vlasenko2016-10-011-12/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>