aboutsummaryrefslogtreecommitdiff
path: root/shell (follow)
Commit message (Collapse)AuthorAgeFilesLines
* ash: enable wait builtin commandRon Yorston2016-05-191-4/+0
|
* ash: use a macro to substitute waitpid_child for waitpidRon Yorston2016-05-181-4/+1
|
* ash: fix use of pid/handle in waitpid_childRon Yorston2016-05-181-34/+65
| | | | | | | | | | Previously spawn was returning a process handle which was treated as a pid in certain circumstances. This resulted in the following failing: find . -type f | sed xargs -n 1 sed -n '1 p' It should output the first line of each file but stopped after the first.
* win32: adjustments to spawn functionsRon Yorston2016-05-181-2/+1
| | | | | | | | Make mingw_spawn_applet and mingw_spawn_1 static. The return value from spawnve is an exit code in synchronous mode and a process handle in asynchronous mode. Pass these upwards without interpretation.
* Merge branch 'busybox' into mergeRon Yorston2016-05-166-6/+13
|\
| * *: slap on a few ALIGN1/2s where appropriateDenys Vlasenko2016-04-222-4/+4
| | | | | | | | | | | | | | | | | | | | 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>
| * ash: bash-compatible $'...' shouldn't expand in double quotesRon Yorston2016-04-155-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * Rewrite iteration through applet names to save a few bytesRon Yorston2016-04-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | ash: adjustment to 'busybox' command in standalone shell modeRon Yorston2016-04-221-19/+5
| | | | | | | | | | | | | | | | | | | | A previous change allowed the command 'busybox' (which isn't an applet) to be invoked by a direct call to the executable, avoiding a PATH lookup. For some reason I also checked that the name of the executable was 'busybox.exe'. This seems unnecessary and prevents the trick from working when the binary is called 'sh.exe', so don't do it any more.
* | ash: improve handling of invalid environment variable namesRon Yorston2016-04-051-6/+6
| | | | | | | | | | | | | | The code to replace invalid characters in environment variable names was being invoked unconditionally because the value of 'end' was altered in the loop to replace backslashes. Avoid this by using a separate loop variable.
* | Merge branch 'busybox' into mergeRon Yorston2016-04-045-0/+13
|\|
| * ash_test: ignore generated filesMike Frysinger2016-03-221-0/+7
| | | | | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
| * ash_test: printenv: fix missing includesMike Frysinger2016-03-221-0/+1
| | | | | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
| * ash: fix corruption of ${#var} if $var contains UTF-8 charactersRon Yorston2016-03-223-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'busybox' into mergeRon Yorston2016-02-221-2/+1
|\|
| * Fix compiling with musl's utmp stubsKylie McClain2016-02-011-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: suppress a compilation warningCristian Ionescu-Idbohrn2016-01-021-1/+1
| | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'busybox' into mergeRon Yorston2015-11-0620-33/+228
|\|
| * ash: add support for bash 'function' keywordRon Yorston2015-11-043-31/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * hush-misc/func_args1.tests: remove "UNFIXED BUG", it does not failDenys Vlasenko2015-11-042-3/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: copy function tests from hush testsuiteRon Yorston2015-11-0416-0/+119
| | | | | | | | | | Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2015-10-3118-62/+107
|\|
| * ash: allow popredir to be called if the stack is emptyRon Yorston2015-10-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: fix EXEXEC status clobberingRon Yorston2015-10-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: add tests for failures of the exec and command builtinsRon Yorston2015-10-304-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * hush: copy for.tests from ash testsuiteDenys Vlasenko2015-10-292-0/+6
| | | | | | | | | | | | This test passes for hush Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: simplify EOF/newline handling in list parserRon Yorston2015-10-291-34/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * Revert "ash: fix a SEGV case in an invalid heredoc" xxxRon Yorston2015-10-291-11/+4
| | | | | | | | | | | | | | | | | | This reverts commit 7e66102f762a7d80715f0c7e5925433256b78cee 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>
| * ash: fix error during recursive processing of here documentRon Yorston2015-10-293-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash tests: make test print test name before it is runDenys Vlasenko2015-10-291-2/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: only allow local variables in functionsRon Yorston2015-10-293-0/+5
| | | | | | | | | | Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: respect -p flag when command builtin is run with -v/-VRon Yorston2015-10-293-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: fix command -- crashDenys Vlasenko2015-10-291-3/+4
| | | | | | | | | | | | | | | | | | | | 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>
| * ash: save a few bytes in code to parse case statementsRon Yorston2015-10-291-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: allow newline after variable name in for loopRon Yorston2015-10-293-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: add test for issue with here documentRon Yorston2015-10-292-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * tidy up strtok useDenys Vlasenko2015-10-231-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2015-10-1317-166/+274
|\|
| * typo fixDenys Vlasenko2015-10-131-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: code shrinkDenys Vlasenko2015-10-111-4/+1
| | | | | | | | | | | | | | function old new delta builtin_wait 347 328 -19 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: shrink umask codeDenys Vlasenko2015-10-101-9/+7
| | | | | | | | | | | | | | function old new delta umaskcmd 258 248 -10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * remove global "jmp_buf die_jmp" from !FEATURE_PREFER_APPLETS buildsDenys Vlasenko2015-10-091-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: "you have mail" should ignore first change in mtimeDenys Vlasenko2015-10-091-1/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: simplify "you have mail" codeDenys Vlasenko2015-10-091-14/+11
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: make dowait() a bit more readable. Logic is unchangedDenys Vlasenko2015-10-091-31/+27
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * build system: -fno-builtin-printfDenys Vlasenko2015-10-073-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: use a more typical form of "print four octal digits" formatDenys Vlasenko2015-10-071-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: more compact API for bb_parse_mode()Denys Vlasenko2015-10-072-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: shrink "umask -S" codeDenys Vlasenko2015-10-071-17/+14
| | | | | | | | | | | | | | | | | | 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>
| * hush: fix umask: umask(022) was setting umask(755)Denys Vlasenko2015-10-072-25/+21
| | | | | | | | | | | | | | | | | | | | 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>