aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* ash: improve performance of ctrl-cRon Yorston2017-08-011-0/+4
| | | | | | | | | | | | | | | | | | | | | The WIN32 port uses a console control handler to detect crtl-c. This replaces the signal handler used in POSIX. The control handler sets an event that can be detected in waitpid_child. However this only works when a wait is in progress, which makes it impossible to break out of a simple shell loop with ctrl-c: while true; do sleep 1 echo hi done Better performance can be achieved by setting the pending_int flag in the control handler, similar to what's done in the signal handler. The deferred signal is processed in int_on. Or at least it would be but for a bug in the WIN32 code to handle shellexec: interrupts weren't being properly turned off and on. So this had to be fixed too.
* win32: rewrite implementation of system(3)Ron Yorston2017-07-311-66/+11
| | | | Rewrite mingw_system using mingw_spawn_proc. Also fix return values.
* win32: check for relative path when spawning processRon Yorston2017-07-311-1/+1
| | | | | | When spawning a process the file should be executed directly if its filename contains any path separator, not just if it's an absolute path.
* unzip: omit special treatment of non-GNU getoptRon Yorston2017-07-301-1/+1
| | | | | | MinGW's getopt is sufficiently similar to GNU's getopt that the code to handle '-x' in the option string isn't required. This doesn't change the behaviour, which was already correct, but saves a few bytes.
* libbb: avoid annoying blank line in help messageRon Yorston2017-07-291-2/+2
| | | | | | The abbreviated commit in the version string recently increased to 9 digits thus causing the first line of the help message to exceed 80 characters.
* platform.h: WIN32 doesn't support '%m' printf specifierRon Yorston2017-07-291-0/+1
|
* win32: add dummy sys/prctl.hRon Yorston2017-07-291-0/+0
|
* lineedit: fix incorrect conflict resolution in bb8d79ead mergeRon Yorston2017-07-291-38/+0
|
* ash: remove old code to tab-complete 'busybox' in standalone shellRon Yorston2017-07-292-18/+3
|
* Merge branch 'busybox' into mergeRon Yorston2017-07-29101-1101/+2017
|\
| * ps: tweak outdated comment, no code changesDenys Vlasenko2017-07-291-5/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ps: implement -o sidDenys Vlasenko2017-07-291-0/+6
| | | | | | | | | | | | | | | | | | | | function old new delta func_sid - 29 +29 out_spec 320 340 +20 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 49/0) Total: 49 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * standalone shell / prefer_applets: fix "exe" in comm fieldsDenys Vlasenko2017-07-291-0/+18
| | | | | | | | | | | | | | function old new delta main 92 106 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: make tryexec(cmd) parameter const charDenys Vlasenko2017-07-291-4/+4
| | | | | | | | | | | | Fewer casts this way. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: make standalone shell tab-complete "busybox"Denys Vlasenko2017-07-292-6/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta busybox_main - 624 +624 packed_usage 31758 31777 +19 applet_names 2638 2646 +8 applet_main 1528 1532 +4 applet_install_loc 191 192 +1 run_applet_and_exit 681 78 -603 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 4/1 up/down: 656/-603) Total: 53 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: support platforms that don't have '%m' printf specifierRon Yorston2017-07-282-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The '%m' conversion specifier prints an error message based on the current value of 'errno'. It is available in the GNU C library, Cygwin (since 2012), uClibc and musl. It is not available in various BSDs, BSD-derived systems (MacOS, Android) or Microsoft Windows. Use a symbol defined in platform.h to control how error messages can be formatted to display the 'errno' message. On platforms that support it use '%m'; on other platforms use '%s' and strerror(). On platforms that have '%m' there is essentially no change in the size of the binary. Otherwise: function old new delta redirect 1287 1310 +23 xtcsetpgrp 27 44 +17 dup2_or_raise 34 51 +17 setinputfile 267 275 +8 .rodata 163379 163371 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 65/-8) Total: 57 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: less hackish implementation of evaltreenr()Denys Vlasenko2017-07-282-6/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Defining a function alias with __attribute__ ((alias("evaltree"),__noreturn__)) is not that usual, and clang had a bug which made it misunderstand this construct. Switch to: ALWAYS_INLINE NORETURN evaltreenr() { evaltree(); unreachable(); } Older gcc's do not know unreachable(), on them we pay the price of having a few extra calls to abort(): function old new delta evalsubshell 151 156 +5 evalpipe 357 362 +5 argstr 1141 1144 +3 On newer gcc, code size does not change. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * unzip: fix regression on big-endian machinesNatanael Copa2017-07-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | This fixes a regression which was introduced with commit 2a0867a5 ("unzip: optional support for bzip2 and lzma") and causes unzip to exit with error when extracting archives: unzip: unsupported method 2048 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * config: more tweaking of help textsDenys Vlasenko2017-07-274-6/+6
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * rdate: tweak comments, no code changesDenys Vlasenko2017-07-271-5/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * inetd: improve --helpt text and config help text.Denys Vlasenko2017-07-272-12/+31
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tweak examples/var_service/*Denys Vlasenko2017-07-272-7/+9
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ed: fix "\n" removal in command line; make "w" set "dirty = 0"Denys Vlasenko2017-07-271-20/+24
| | | | | | | | | | | | | | | | | | | | function old new delta doCommands 2184 2226 +42 getNum 345 343 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 42/-2) Total: 40 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ed: code shrinkDenys Vlasenko2017-07-271-51/+43
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta findString 117 115 -2 skip_blank 16 - -16 getNum 369 345 -24 doCommands 2448 2183 -265 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/3 up/down: 0/-307) Total: -307 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ed: fix --help and reorder functions, no code changesDenys Vlasenko2017-07-271-548/+516
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * swapon: do not use FEATURE_MOUNT_LABEL, have your own FEATURE_SWAPONOFF_LABELDenys Vlasenko2017-07-273-2/+11
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * config: trim/improve item names and help texts, take 2Denys Vlasenko2017-07-2716-74/+81
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * config: trim/improve item names and help texts.Denys Vlasenko2017-07-272-53/+48
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: force inlining of a trivial functionDenys Vlasenko2017-07-261-1/+1
| | | | | | | | | | | | | | function old new delta bltinlookup 5 - -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: revert previous implementation of "A=1 A=2 B=$A cmd" codeDenys Vlasenko2017-07-261-47/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reverts this: commit 0e6f661e23d358cca104c24f8438d0ec64df32f1 Date: Fri Feb 15 15:02:15 2008 +0000 ash: handle "A=1 A=2 B=$A; echo $B". closes bug 947. A different fix from upstream has been imported by previous six commits. Last seven commits, cumulative: function old new delta poplocalvars - 314 +314 mklocal - 288 +288 pushlocalvars - 48 +48 evalcommand 1372 1408 +36 unwindlocalvars - 22 +22 ash_main 1022 1029 +7 setvar 167 172 +5 localvar_stack - 4 +4 setvareq 303 302 -1 evalcase 271 269 -2 subevalvar 1202 1198 -4 localvars 4 - -4 cmdenviron 4 - -4 expandarg 984 973 -11 evalvar 589 574 -15 argstr 1164 1141 -23 dotcmd 335 303 -32 bltinlookup 51 5 -46 varvalue 709 596 -113 evalfun 456 270 -186 localcmd 364 44 -320 ------------------------------------------------------------------------------ (add/remove: 5/2 grow/shrink: 3/11 up/down: 724/-761) Total: -37 bytes text data bss dec hex filename 915353 485 6888 922726 e1466 busybox_old 915320 485 6880 922685 e143d busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [VAR] Fix loss of variables when hash collidesDenys Vlasenko2017-07-261-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Tue, 6 Jul 2010 17:40:53 +0800 [VAR] Fix loss of variables when hash collides Brian Koropoff reported that the new var patches broke the following script: #!/bin/dash GDM_LANG="bar" OPTION="foo" unset GDM_LANG # OPTION has mysteriously become unset echo "$OPTION" He correctly diagnosed this as a result of removing all variables in the hash chain preceding the one that should be removed in setvareq. He also provided a patch to fix this. This patch is based on his but without keeping the original vpp. As a result, we now store new variables at the end of the hash chain instead of the beginning. To make this work, setvareq/setvar now returns the vp pointer modified. In case they're used to unset a variable the pointer returned is undefined. This is because mklocal needs it and used to get it by assuming that the new variable always appear at the beginning of the chain. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [VAR] Do not poplocalvars prematurely on regular utilitiesDenys Vlasenko2017-07-261-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 27 May 2010 11:50:19 +0800 [VAR] Do not poplocalvars prematurely on regular utilities The recent cmdenviron removal broke regular utilities by calling poplocalvars too early. This patch fixes that by postponing the poplocalvars for regular utilities until they have completed. In order to ensure that local still works, it is now a special built-in. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [VAR] Fix poplocalvar on abnormal exit from functionDenys Vlasenko2017-07-261-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 27 May 2010 11:32:55 +0800 [VAR] Fix poplocalvar on abnormal exit from function The new localvar code broke the abnormal exit from functions and built-ins by not restoring the original localvar state. This patch fixes this by storing the previous localvar state so that we always unwind correctly in case of an abnormal exit. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [VAR] Replace cmdenviron with localvarsDenys Vlasenko2017-07-261-27/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Wed, 26 May 2010 18:54:19 +0800 [VAR] Replace cmdenviron with localvars This patch replaces the cmdenviron mechanism for temporary command variables with the localvars mechanism used by functions. This reduces code size, and more importantly, makes the variable assignment take effect immediately as required by POSIX. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [VAR] Fix poplocalvar leakDenys Vlasenko2017-07-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Tue, 25 May 2010 18:14:32 +0800 [VAR] Fix poplocalvar leak When a variable is marked as local, we set VSTRFIXED on its vp recored. However, poplocalvar never clears this flag for variables that were unset to begin with. Thus if you ever made an unset variable local, it would get the VSTRFIXED bit and stick around forever. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [VAR] Add localvars nestingDenys Vlasenko2017-07-261-13/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Mon, 24 May 2010 15:31:27 +0800 [VAR] Add localvars nesting This patch adds localvars nesting infrastructure so we can reuse the localvars mechanism for command evaluation. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: alloc slightly smaller buffer in cvtnum(); faster unsetvar()Denys Vlasenko2017-07-261-9/+13
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: fix redir_leak.tests if STANDALONE=yDenys Vlasenko2017-07-261-0/+1
| | | | | | | | | | | | | | | | If STANDALONE and we run a NOEXEC applet, saved copies of redirected fds were visible for the child. They have CLOEXEC bit, yes, but we do not exec in this case. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: remove ${#+} tests, it is not a valid constructDenys Vlasenko2017-07-264-6/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix ${##}, ${#?}, ${#!} handlingDenys Vlasenko2017-07-267-9/+106
| | | | | | | | | | | | | | | | | | | | function old new delta parse_dollar 786 820 +34 expand_one_var 1579 1592 +13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 47/0) Total: 47 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [SHELL] Optimize dash -c "command" to avoid a forkDenys Vlasenko2017-07-251-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 7 Jul 2011 13:58:48 +0800 [SHELL] Optimize dash -c "command" to avoid a fork On Sun, Apr 10, 2011 at 07:36:49AM +0000, Jonathan Nieder wrote: > From: Jilles Tjoelker <jilles@stack.nl> > Date: Sat, 13 Jun 2009 16:17:45 -0500 > > This change only affects strings passed to -c, when the -s option is > not used. > > Use the EV_EXIT flag to inform the eval machinery that the string > being passed is the entirety of input. This way, a fork may be > omitted in many special cases. > > If there are empty lines after the last command, the evalcmd will not > see the end early enough and forks will not be omitted. The same thing > seems to happen in bash. > > Example: > sh -c 'ps lT' > No longer shows a shell process waiting for ps to finish. > > [jn: ported from FreeBSD SVN r194128. Bugs are mine.] > > Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Instead of detecting EOF using the input layer, I'm going to use the parser instead. In either case, we always have to read ahead in order to complete the parsing of the previous node. Therefore we always know whether there is more to come, except in the case where we see a newline/semicolon or similar. For the purposes of sh -c, this should be sufficient. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta evalstring 190 224 +34 ash_main 1014 1022 +8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 42/0) Total: 42 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: allow "trap NUM [SIG]..." syntaxDenys Vlasenko2017-07-254-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | While at it, make get_signum() return -1 for numeric strings >= NSIG. function old new delta trapcmd 292 306 +14 get_signum 295 300 +5 builtin_trap 413 412 -1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 19/-1) Total: 18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [REDIR] Replace GPL noclobberopen code with the FreeBSD versionDenys Vlasenko2017-07-251-64/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 10 Mar 2011 16:52:13 +0800 [REDIR] Replace GPL noclobberopen code with the FreeBSD version Replace noclobberopen() from bash with the FreeBSD code for noclobber opens. This also reduces code size by eliminating an unnecessary check. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta changepath 192 194 +2 localcmd 366 364 -2 expmeta 521 517 -4 redirect 1210 1135 -75 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 2/-81) Total: -79 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: sync up with dash with respect to redirection escapingDenys Vlasenko2017-07-251-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We fixed the problem differently than they. Let's not deviate. Upstream commit: Date: Thu, 27 May 2010 20:07:29 +1000 [EXPAND] Fix corruption of redirections with byte 0x81 In other ash variants, a partial implementation of ksh-like cmd >file* adds and removes CTLESC bytes ('\x81') in redirection filenames, preserving 8-bit transparency. Long ago, dash removed the code to add the CTLESC bytes, but not the code to remove them, causing corruption of filenames containing CTLESC. This commit removes the code to remove the CTLESC bytes. The CTLESC byte occurs frequently in UTF-8 encoded non-Latin text. This bug has been reported various times to Ubuntu and Debian (e.g. Launchpad Ubuntu #422298). This patch is the same as the one submitted by Alexander Korolkov in Ubuntu #422298. Signed-off-by: Jilles Tjoelker <jilles@stack.nl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta changepath 194 192 -2 expandarg 1000 984 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18) Total: -18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [VAR] Move unsetvar functionality into setvareqDenys Vlasenko2017-07-256-46/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Tue, 25 May 2010 20:55:05 +0800 [VAR] Move unsetvar functionality into setvareq This patch moves the unsetvar code into setvareq so that we can no have a pathological case of an unset variable hanging around unless it has a bit pinning it like VEXPORT. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta setvareq 227 303 +76 expmeta 517 521 +4 localcmd 364 366 +2 unsetcmd 96 76 -20 unsetvar 129 7 -122 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/2 up/down: 82/-142) Total: -60 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: import param_expand_default.tests from hushDenys Vlasenko2017-07-253-2/+34
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: treat ${#?} as "length of $?"Denys Vlasenko2017-07-255-5/+115
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: add a few tests from hush-vars/*Denys Vlasenko2017-07-2510-23/+283
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * volume_id: enable minix detectionDenys Vlasenko2017-07-253-27/+35
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta volume_id_probe_minix - 87 +87 fs2 64 68 +4 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 1/0 up/down: 91/0) Total: 91 bytes Patch by wdlkmpx <wdlkmpx@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: fix comment, no code changesDenys Vlasenko2017-07-241-3/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>