aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* ash: unbreak PS1 parsing after "ash: parser: Add syntax stack..." commitDenys Vlasenko2018-04-041-1/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: support "f() (cmd)" functionsDenys Vlasenko2018-04-036-40/+59
| | | | | | | | | Many other shells support this construct function old new delta parse_stream 2950 3018 +68 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix mishandling of "true | f() { echo QWE; }"Denys Vlasenko2018-04-031-0/+9
| | | | | | | function old new delta run_pipe 1820 1826 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix "set -e; false || x=1; echo OK"Denys Vlasenko2018-04-035-7/+43
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: one-word, no-globbing handling of local/export/readonly argsDenys Vlasenko2018-04-031-21/+32
| | | | | | | function old new delta done_word 738 790 +52 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: parser: Fix parameter expansion inside inner double quotesDenys Vlasenko2018-04-023-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Upstream email: parser: Fix parameter expansion inside inner double quotes The parsing of parameter expansion inside inner double quotes breaks because we never look for ENDVAR while innerdq is true. echo "${x#"${x+''}"''} This patch fixes it by pushing the syntax stack if innerdq is true and we enter a new parameter expansion. This patch also fixes a corner case where a bad substitution error occurs within arithmetic expansion. Reported-by: Denys Vlasenko <vda.linux@googlemail.com> Fixes: ab1cecb40478 (" parser: Add syntax stack for recursive...") Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta readtoken1 2880 2898 +18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix a backslash-removal bug in caseDenys Vlasenko2018-04-025-3/+37
| | | | | | | function old new delta run_list 1270 1053 -217 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: expand: Fix bugs with words connected to the right of $@Denys Vlasenko2018-04-025-4/+13
| | | | | | | | | | | | | | | Upstream email: This is actually composed of two bugs. First of all our tracking of quotemark is wrong so anything after "$@" becomes quoted. Once we fix that then the problem is that the first space character after "$@" is not recognised as an IFS. This patch fixes both. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: redir: Fix typo in noclobber codeDenys Vlasenko2018-04-021-1/+1
| | | | | | Upstream commit "redir: Fix typo in noclobber code" Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: parser: Fix single-quoted patterns in here-documentsDenys Vlasenko2018-04-023-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: From: Herbert Xu <herbert@gondor.apana.org.au> Date: Fri, 9 Mar 2018 23:07:53 +0800 parser: Fix single-quoted patterns in here-documents The script x=* cat <<- EOF ${x#'*'} EOF prints * instead of nothing as it should. The problem is that when we're in sqsyntax context in a here-document, we won't add CTLESC as we should. This patch fixes it: Reported-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>
* hush: remove stray debugging printoutDenys Vlasenko2018-04-021-1/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: parser: Add syntax stack for recursive parsingDenys Vlasenko2018-04-0219-121/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This closes 10821. Upstream patch: From: Herbert Xu <herbert@gondor.apana.org.au> Date: Fri, 9 Mar 2018 00:14:02 +0800 parser: Add syntax stack for recursive parsing Without a stack of syntaxes we cannot correctly these two cases together: "${a#'$$'}" "${a#"${b-'$$'}"}" A recursive parser also helps in some other corner cases such as nested arithmetic expansion with paratheses. This patch adds a syntax stack allocated from the stack using alloca. As a side-effect this allows us to remove the naked backslashes for patterns within double-quotes, which means that EXP_QPAT also has to go. This patch also fixes removes any backslashes that precede right braces when they are present within a parameter expansion context, and backslashes that precede double quotes within inner double quotes inside a parameter expansion in a here-document context. The idea of a recursive parser is based on a patch by Harald van Dijk. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> var_bash3, var_bash4 and var_bash6 tests are updated with the output given by bash-4.3.43 With this patch, the following tests now pass for ash: dollar_repl_slash_bash2.tests squote_in_varexp2.tests squote_in_varexp.tests var_bash4.tests function old new delta readtoken1 2615 2874 +259 synstack_push - 54 +54 evalvar 574 571 -3 rmescapes 330 310 -20 subevalvar 1279 1258 -21 argstr 1146 1107 -39 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/4 up/down: 313/-83) Total: 230 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: update information comment about heredoc discrepancyDenys Vlasenko2018-04-011-7/+12
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: new function bb_die_memory_exhaustedDenys Vlasenko2018-04-017-26/+32
| | | | | | | | | | | | | | | | | | | | function old new delta bb_die_memory_exhausted - 10 +10 xstrdup 28 23 -5 xsetenv 27 22 -5 xrealloc 32 27 -5 xputenv 22 17 -5 xmalloc 30 25 -5 xfdopen_helper 40 35 -5 xasprintf 44 39 -5 wget_main 2387 2382 -5 open_socket 54 49 -5 glob_brace 419 414 -5 bb_get_chunk_from_file 146 141 -5 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/11 up/down: 10/-55) Total: -45 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sed: prevent overflow of length from bb_get_chunk_from_fileQuentin Rameau2018-04-013-6/+9
| | | | | | | | | | | | | | | This fragment did not work right: temp = bb_get_chunk_from_file(fp, &len); if (temp) { /* len > 0 here, it's ok to do temp[len-1] */ char c = temp[len-1]; With "int len" _sign-extending_, temp[len-1] can refer to a wrong location if len > 0x7fffffff. Signed-off-by: Quentin Rameau <quinq@fifth.space> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: remove unnecessary variable in xmalloc_fgetsQuentin Rameau2018-04-011-3/+1
| | | | | Signed-off-by: Quentin Rameau <quinq@fifth.space> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: add a comment where we differ from bash wrt heredoc EOF mark handlingDenys Vlasenko2018-04-013-15/+8
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* parser: Fix backquote support in here-document EOF markDenys Vlasenko2018-04-015-0/+36
| | | | | | | | | | | | | | | | | | | | Upstream commit: Author: Herbert Xu <herbert@gondor.apana.org.au> Date: Thu Mar 15 18:27:30 2018 +0800 parser: Fix backquote support in here-document EOF mark Currently using backquotes in a here-document EOF mark is broken because dash tries to do command substitution on it. This patch fixes it by checking whether we're looking for an EOF mark during tokenisation. Reported-by: Harald van Dijk <harald@gigawatt.nl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> With added fix for quoted-ness of the EOF mark. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash,hush: handle a few more bkslash-newline casesDenys Vlasenko2018-04-0110-3/+53
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shells: fix var_LINENO1.tests false positive, add it to ash tests tooDenys Vlasenko2018-03-313-1/+15
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix heredoc_bkslash_newline1.tests failureDenys Vlasenko2018-03-311-35/+42
| | | | | | | | function old new delta parse_stream 2787 2827 +40 builtin_type 117 115 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: use pgetc_eatbnl() in more placesDenys Vlasenko2018-03-317-35/+191
| | | | | | | | | | | | | | | | | | | | | Part of upstream commit: Date: Thu Mar 8 08:37:11 2018 +0100 Author: Harald van Dijk <harald@gigawatt.nl> parser: use pgetc_eatbnl() in more places dash has a pgetc_eatbnl function in parser.c which skips any backslash-newline combinations. It's not used everywhere it could be. There is also some duplicated backslash-newline handling elsewhere in parser.c. Replace most of the calls to pgetc() with calls to pgetc_eatbnl() and remove the duplicated backslash-newline handling. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Not adding "readtoken1(pgetc_eatbnl(), DQSYNTAX..." changes, since readtoken1() handles the "starts with backslash + newline" case itself. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: 'nolog' and 'debug' options cause "$-" to wreak havocMartijn Dekker2018-03-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Tue Mar 6 17:40:37 2018 +0000 expand: 'nolog' and 'debug' options cause "$-" to wreak havoc Op 29-03-17 om 20:02 schreef Martijn Dekker: > Bug: if either the 'nolog' or the 'debug' option is set, trying to > expand "$-" silently aborts parsing of an entire argument. > > $ dash -o nolog -c 'set -fuC; echo "|$- are the options|"; set +o nolog; echo "|$- are the options|"' > | > |uCf are the options| > $ dash -o debug -c 'set -fuC; echo "|$- are the options|"; set +o debug; echo "|$- are the options|"' > | > |uCf are the options| This turned out to be easy to fix. The routine producing the "$-" expansion failed to skip options for which there is no option letter, but only a long-form name. In dash, 'nolog' and 'debug' are currently the only two such options. Patch below. - Martijn Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> In bbox ash, pipefail is the option which exhibited this. Signed-off-by: Martijn Dekker <martijn@inlv.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* stat: fix a typo: s/romfs/ramfs/, closes 10876Denys Vlasenko2018-03-311-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix a signedness bugDenys Vlasenko2018-03-311-1/+1
| | | | | | | | | | | | | | | | Testcase: set -- a ""; space=" "; printf "<%s>\n" "$@"$space Before: <a > After: <a> <> It usually does not bite since bbox forces -funsigned-char build. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash,hush: new test dollar_repl_slash_bash2.testsDenys Vlasenko2018-03-304-0/+6
| | | | | | This fails for ash. hush works. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix "char == CTLfoo" comparison signedness bugDenys Vlasenko2018-03-301-3/+3
| | | | | | | It usually does not bite since bbox forces -funsigned-char build. But for some reason void linux people disabled that. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: use F_DUPFD_CLOEXEC and O_CLOEXECDenys Vlasenko2018-03-301-9/+16
| | | | | | | | | | | | function old new delta setjobctl 371 367 -4 setinputfile 226 220 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-10) Total: -10 bytes Based on patch by Mark Marshall <mark.marshall@omicronenergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* examples/var_service: new example: dnsmasq serviceDenys Vlasenko2018-03-307-0/+165
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* cpio: extract "unsafe" symlinks the same way tar/unzip doesNatanael Copa2018-03-301-0/+2
| | | | | | | | function old new delta cpio_main 588 596 +8 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* svok: new applet (daemontools compat)Denys Vlasenko2018-03-303-7/+61
| | | | | | | | | | | | | | function old new delta svok_main - 127 +127 packed_usage 32705 32757 +52 applet_names 2756 2761 +5 applet_main 1588 1592 +4 bb_banner 46 47 +1 sv 1286 1284 -2 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 4/1 up/down: 189/-2) Total: 187 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ifplugd service example: always run up/down script on startupDenys Vlasenko2018-03-301-8/+9
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ifplugd: if SIOCSIFFLAGS fails with EADDRNOTAVAIL, don't dieStefan Agner2018-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using ifplugd on a RNDIS interface with monitor mode, using SIOCSIFFLAGS seems to fail with EADDRNOTAVAIL. Treat it the same as if iface disappeared again. This has been observed on a Tegra TK1 using Linux 4.14. There seem to be a race when the kernel is creating the device: ifplugd(usb0): started: BusyBox v1.24.1 (2018-03-27 09:47:48 CEST) ifplugd(usb0): interface doesn't exist, waiting ifplugd(usb0): interface appeared ifplugd(usb0): upping interface ifplugd(usb0): setting interface flags failed: Cannot assign requested address <exit> With this patch ifplugd is successful in upping the device the second time around: ifplugd(usb0): upping interface ifplugd(usb0): using SIOCETHTOOL detection mode ifplugd(usb0): interface appeared ifplugd(usb0): upping interface ifplugd(usb0): setting interface flags failed: Cannot assign requested address ifplugd(usb0): interface appeared ifplugd(usb0): upping interface ifplugd(usb0): using SIOCETHTOOL detection mode ifplugd(usb0): link is up ifplugd(usb0): executing '/etc/ifplugd/ifplugd.usb.action usb0 up' ifplugd up ifplugd(usb0): exit code: 0 function old new delta up_iface 120 127 +7 Signed-off-by: Stefan Agner <stefan@agner.ch> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* fbsplash: support configurable image positionPeter Korsgaard2018-03-291-9/+12
| | | | | | | | | | | | | | | | | | | For some setups (E.G. for supporting different screen resolutions), positioning the image somewhere else than the top left corner may be interesting. Add support for IMG_LEFT/IMG_TOP settings to specify the image location, similar to how it is done for the progress bar. function old new delta fbsplash_main 994 1038 +44 static.param_names 57 74 +17 packed_usage 32631 32647 +16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 77/0) Total: 77 bytes Signed-off-by: Peter Korsgaard <peter@korsgaard.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* grep: fix echo "aa" | busybox grep -F -w "a" (should not match)Denys Vlasenko2018-03-292-1/+7
| | | | | | | function old new delta grep_file 1461 1470 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* fstrim: do not check that specified file is on a block deviceDenys Vlasenko2018-03-291-3/+11
| | | | | | | | | Kernel will surely inform us in FITRIM does not make sense on a given file. function old new delta fstrim_main 241 221 -20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: add a FIXME commentDenys Vlasenko2018-03-281-0/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash,hush: fix "saved" redirected fds still visible in childrenDenys Vlasenko2018-03-2814-13/+92
| | | | | | | | | | Based on a patch by Mark Marshall <mark.marshall@omicronenergy.com> function old new delta dup_CLOEXEC - 49 +49 fcntl_F_DUPFD 46 - -46 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: use BUILD_BUG_ON in utoa_to_buf()Denys Vlasenko2018-03-281-4/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ifupdown: do not fail if interface disappears during ifdownKaarle Ritvanen2018-03-281-0/+6
| | | | | | | | | | | | | | | Interface may not exist because it got deleted by an ifdown hook script earlier. This may happen when a virtual interface, such as VLAN, has multiple iface blocks defined. function old new delta static_down6 14 40 +26 static_down 54 70 +16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 42/0) Total: 42 bytes Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ioctl(SIOCGIFINDEX) does not require clearing of entire ifrDenys Vlasenko2018-03-273-3/+3
| | | | | | | | | | function old new delta INET6_setroute 492 472 -20 do_iplink 1357 1330 -27 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-47) Total: -47 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* netstat: produce numeric-ip output for non-resolved namesMark Marshall2018-03-271-2/+5
| | | | | | | | | | | If we don't ask for numerical output, and the symbolic look-up failed we used to get "(null)", but the numeric output would be better. function old new delta ip_port_str 109 121 +12 Signed-off-by: Mark Marshall <mark.marshall@omicronenergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ssl_client: fix option parsingRon Yorston2018-03-201-1/+1
| | | | | | | | The wrong character was used to indicate options taking an integer parameter. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* top: fix "warning: unused variable new_mask"Denys Vlasenko2018-03-191-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tar: add -o and -k to short --help tooDenys Vlasenko2018-03-161-5/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tar: add -k and -o to --helpDenys Vlasenko2018-03-161-3/+3
| | | | | | | -o Don't restore user:group -k Don't replace existing files Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tcpsvd: fix fallout from opt_complementary removalDenys Vlasenko2018-03-111-3/+8
| | | | | | | | text data bss dec hex filename 933035 473 6836 940344 e5938 busybox_old 933051 473 6836 940360 e5948 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* readprofile: code shrinkDenys Vlasenko2018-03-111-34/+33
| | | | | | | | | | | | | | function old new delta defaultpro 14 - -14 defaultmap 17 - -17 readprofile_main 1762 1719 -43 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-74) Total: -74 bytes text data bss dec hex filename 933081 473 6836 940390 e5966 busybox_old 933035 473 6836 940344 e5938 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ntpd: choose initial FREQHOLD_cnt dynamicallyDenys Vlasenko2018-03-111-12/+54
| | | | | | | function old new delta update_local_clock 834 858 +24 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* udhcpd: clamp down huge auto_times to ~2M seconds, better EINTR poll handlingDenys Vlasenko2018-03-111-5/+20
| | | | | | | | | | | EINTR _should_ only happen on two signals we trap, and safe_poll _should_ work here just fine, but there were kernel bugs where spurious EINTRs happen (e.g. on ptrace attach). Be safe. function old new delta udhcpd_main 1437 1468 +31 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>