aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Only disable tracing embedded scripts if they can't be listedembedRon Yorston2018-10-221-0/+2
|
* Allow shell scripts to be embedded in the binaryRon Yorston2018-10-221-1/+139
| | | | | | | | | | | | | | | | | | | | | | | | To assist in the deployment of shell scripts it may be convenient to embed them in the BusyBox binary. This patch adds two configuration options to the shell: - 'Embed scripts in the binary' takes any files in the directory 'embed', concatenates them with null separators, compresses them and embeds them in the binary. - 'Allow the contents of embedded scripts to be listed' makes the shell argument '-L name' list the contents of the named script. Both options are off by default. When scripts are embedded in the binary: - The shell argument '-L' lists the names of the scripts. - Scripts can be run as 'sh name arg...'. - An alias is added for each script, equivalent to "alias name='sh name'".
* Merge branch 'busybox' into mergeRon Yorston2018-09-101-53/+74
|\
| * ash: expand: Do not quote backslashes in unquoted parameter expansionDenys Vlasenko2018-08-071-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Wed, 28 Mar 2018 18:37:51 +0800 expand: Do not quote backslashes in unquoted parameter expansion Here is a better example: a="/*/\nullx" b="/*/\null"; printf "%s\n" $a $b dash currently prints /*/\nullx /*/\null bash prints /*/\nullx /dev/null You may argue the bash behaviour is inconsistent but it actually makes sense. What happens is that quote removal only applies to the original token as seen by the shell. It is never applied to the result of parameter expansion. Now you may ask why on earth does the second line say "/dev/null" instead of "/dev/\null". Well that's because it is not the quote removal step that removed the backslash, but the pathname expansion. The fact that the /de\v does not become /dev even though it exists is just the result of the optimisation to avoid unnecessarily calling stat(2). I have checked POSIX and I don't see anything that forbids this behaviour. So going back to dash yes I think we should adopt the bash behaviour for pathname expansion and keep the existing case semantics. This patch does exactly that. Note that this patch does not work unless you have already applied https://patchwork.kernel.org/patch/10306507/ because otherwise the optimisation mentioned above does not get detected correctly and we will end up doing quote removal twice. This patch also updates expmeta to handle naked backslashes at the end of the pattern which is now possible. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta expmeta 618 653 +35 memtodest 146 147 +1 Tested to work with both ASH_INTERNAL_GLOB on and off. hush does not handle this correctly. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: exec: Return 126 on most errors in shellexecDenys Vlasenko2018-08-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Sat, 19 May 2018 02:39:37 +0800 exec: Return 126 on most errors in shellexec Currently when shellexec fails on most errors the shell will exit with exit status 2. This patch changes it to 126 in order to avoid ambiguities with the exit status from a successful exec. The errors that result in 127 has also been expanded to include ENOTDIR, ENAMETOOLONG and ELOOP. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta shellexec 245 254 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: eval: Restore input files in evalcommandDenys Vlasenko2018-08-051-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Tue, 27 Mar 2018 00:39:35 +0800 eval: Restore input files in evalcommand When evalcommand invokes a command that modifies parsefile and then bails out without popping the file, we need to ensure the input file is restored so that the shell can continue to execute. Reported-by: Martijn Dekker <martijn@inlv.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta unwindfiles - 20 +20 evalcommand 1635 1653 +18 getoptscmd 584 595 +11 popallfiles 20 10 -10 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/1 up/down: 49/-10) Total: 39 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: parser: Fix parsing of ${}Denys Vlasenko2018-08-051-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Tue, 3 Apr 2018 00:40:25 +0800 parser: Fix parsing of ${} dash -c 'echo ${}' should print "Bad subtitution" but instead fails with "Syntax error: Missing '}'". This is caused by us reading an extra character beyond the right brace. This patch fixes it so that this construct only fails during expansion rather than during parsing. Fixes: 3df3edd13389 ("[PARSER] Report substition errors at...") Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta readtoken1 2907 2916 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash,hush: fold shell_builtin_read() way-too-many params into a struct paramDenys Vlasenko2018-08-051-23/+15
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta getoptscmd 587 584 -3 readcmd 240 224 -16 shell_builtin_read 1426 1399 -27 builtin_read 210 182 -28 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-74) Total: -74 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: expand: Fix ghost fields with unquoted $@/$*Denys Vlasenko2018-08-051-12/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Fri, 23 Mar 2018 18:58:47 +0800 expand: Fix ghost fields with unquoted $@/$* You're right. The proper fix to this is to ensure that nulonly is not set in varvalue for $*. It should only be set for $@ when it's inside double quotes. In fact there is another bug while we're playing with $@/$*. When IFS is set to a non-whitespace character such as :, $* outside quotes won't remove empty fields as it should. This patch fixes both problems. Reported-by: Martijn Dekker <martijn@inlv.org> Suggested-by: Harald van Dijk <harald@gigawatt.nl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta argstr 1111 1113 +2 evalvar 571 569 -2 varvalue 579 576 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 2/-5) Total: -3 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: var: Set IFS to fixed value at start timeDenys Vlasenko2018-08-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Sat, 19 May 2018 02:39:43 +0800 var: Set IFS to fixed value at start time This patch forces the IFS variable to always be set to its default value, regardless of the environment. It also removes the long unused IFS_BROKEN code. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: eval: Variable assignments on functions are no longer persistentDenys Vlasenko2018-08-051-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Wed, 4 Apr 2018 17:54:01 +0800 eval: Variable assignments on functions are no longer persistent Dirk Fieldhouse <fieldhouse@gmx.net> wrote: > In POSIX.1-2017 ("simultaneously IEEE Std 1003.1™-2017 and The Open > Group Technical Standard Base Specifications, Issue 7") > <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09>, > we read under '2.9.1 Simple Commands' > > "Variable assignments shall be performed as follows: > ... > - If the command name is a standard utility implemented as a function > (see XBD Utility), the effect of variable assignments shall be as if the > utility was not implemented as a function. > ... > - If the command name is a function that is not a standard utility > implemented as a function, variable assignments shall affect the current > execution environment during the execution of the function. It is > unspecified: > > * Whether or not the variable assignments persist after the > completion of the function > > * Whether or not the variables gain the export attribute during > the execution of the function > > * Whether or not export attributes gained as a result of the > variable assignments persist after the completion of the function (if > variable assignments persist after the completion of the function)" POSIX used to require the current dash behaviour. However, you're right that this is no longer the case. This patch will remove the persistence of the variable assignment. I have considered the exporting the variables during the function execution but have decided against it because: 1) It makes the code bigger. 2) dash has never done this in the past. 3) You cannot use this portably anyway. Reported-by: Dirk Fieldhouse <fieldhouse@gmx.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta evalcommand 1606 1635 +29 evalcase 313 317 +4 evalfun 280 268 -12 pushlocalvars 48 - -48 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 2/1 up/down: 33/-60) Total: -27 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash,hush: properly handle ${v//pattern/repl} if pattern starts with /Denys Vlasenko2018-08-041-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | Closes 2695 function old new delta parse_dollar 762 790 +28 subevalvar 1258 1267 +9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 37/0) Total: 37 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox'Ron Yorston2018-07-251-1/+2
|\|
| * hush: add "heredoc.tests" from ash, tweak ash "is a function" messageDenys Vlasenko2018-07-241-1/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2018-05-131-28/+64
|\|
| * ash: expand: Fix buffer overflow in expandmetaDenys Vlasenko2018-04-141-25/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Sun, 25 Mar 2018 16:38:00 +0800 expand: Fix buffer overflow in expandmeta The native version of expandmeta allocates a buffer that may be overrun for two reasons. First of all the size is 1 byte too small but this is normally hidden because the minimum size is rounded up to 2048 bytes. Secondly, if the directory level is deep enough, any buffer can be overrun. This patch fixes both problems by calling realloc when necessary. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta expmeta 517 635 +118 expandarg 990 996 +6 mklocal 288 290 +2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 126/0) Total: 126 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: parser: Allow newlines within parameter substitutionDenys Vlasenko2018-04-111-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 22 Mar 2018 21:41:24 +0800 parser: Allow newlines within parameter substitution On Fri, Mar 16, 2018 at 11:27:22AM +0800, Herbert Xu wrote: > On Thu, Mar 15, 2018 at 10:49:15PM +0100, Harald van Dijk wrote: > > > > Okay, it can be trivially modified to something that does work in other > > shells (even if it were actually executed), but gets rejected at parse time > > by dash: > > > > if false; then > > : ${$+ > > } > > fi > > That's just a bug in dash's parser with ${} in general, because > it bombs out without the if clause too: > > : ${$+ > } This patch fixes the parsing of newlines with parameter substitution. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: do not drop backslash from eval 'echo ok\'Denys Vlasenko2018-04-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | newer bash does not drop it, most other shells too function old new delta unbackslash 39 57 +18 parse_stream 2753 2751 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 18/-2) Total: 16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: add comments about [[, no code changesDenys Vlasenko2018-04-101-1/+14
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: if "[[" bashism is not supported, do not handle it anywhereDenys Vlasenko2018-04-101-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: trivial code shrinkDenys Vlasenko2018-04-101-1/+2
| | | | | | | | | | | | | | function old new delta parse_command 1677 1674 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: make loopnest a global variableRon Yorston2018-04-131-1/+2
| | | | | | | | Fixes the test ash-misc/break5.tests.
* | ash: make commandname a global variableRon Yorston2018-04-121-2/+7
| | | | | | | | | | | | | | commandname is static so isn't copied during forkshell. This was causing the arith-tests script in the shell test suite to fail because without commandname some error reports were missing line numbers.
* | ash: make struct forkshell a local variable in evalbackcmdRon Yorston2018-04-101-7/+7
| | | | | | | | | | | | There's no reason for the forkshell structure to be passed between expbackq and evalbackcmd in the backcmd structure. It can be a local variable, as in the other similar cases.
* | Merge branch 'busybox' into mergeRon Yorston2018-04-091-104/+147
|\|
| * bzip2: fix two crashes on corrupted archivesDenys Vlasenko2018-04-081-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As it turns out, longjmp'ing into freed stack is not healthy... function old new delta unpack_usage_messages - 97 +97 unpack_bz2_stream 369 409 +40 get_next_block 1667 1677 +10 get_bits 156 155 -1 start_bunzip 212 183 -29 bb_show_usage 181 120 -61 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/3 up/down: 147/-91) Total: 56 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: implement "hush -s"Denys Vlasenko2018-04-051-1/+1
| | | | | | | | | | | | | | | | | | | | function old new delta hush_main 1015 1031 +16 packed_usage 32757 32745 -12 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 16/-12) Total: 4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * 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>
| * ash: parser: Fix parameter expansion inside inner double quotesDenys Vlasenko2018-04-021-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: expand: Fix bugs with words connected to the right of $@Denys Vlasenko2018-04-021-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: parser: Add syntax stack for recursive parsingDenys Vlasenko2018-04-021-97/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | win32: more backslash to slash conversionsRon Yorston2018-04-081-0/+3
| | | | | | | | | | | | | | | | | | Convert backslashes to slashes: - in the main program's argv[0] - in the shell's file argument Also, fix the code to remove the .exe extension from argv[0] in the main program.
* | ps: indicate forkshell processes in listingRon Yorston2018-04-051-3/+4
| |
* | ps: obtain applet names from other BusyBox processesRon Yorston2018-04-041-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the code which passed applet names to child processes using environment variables. This only allowed ps to display names for its ancestors. Instead attempt to read applet names from the memory of unrelated processes. The Microsoft documentation alone wasn't enough to figure out how to do this. Additional hints from: https://stackoverflow.com/questions/4298331/exe-or-dll-image-base-address https://stackoverflow.com/questions/14467229/get-base-address-of-process
* | ash: reinstate applet name variable after forkshellRon Yorston2018-04-031-0/+7
| | | | | | | | | | | | When 'sh --forkshell' is invoked the BB_APPLET_<pid> environment variable is set, but then it's cleared when the environment of the child process is restored. Reinstate it in reinitvar.
* | ash: minor forkshell fixesRon Yorston2018-04-021-7/+5
| | | | | | | | | | | | | | | | - update forkshell_evalbackcmd to match the non-MinGW code; - increase the size of the buffer to hold the forkshell handle for 64-bit machines; - use memcpy to copy the globals_var structure to avoid copying bits by hand.
* | Merge branch 'busybox' into mergeRon Yorston2018-04-021-53/+49
|\|
| * parser: Fix backquote support in here-document EOF markDenys Vlasenko2018-04-011-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-011-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: use pgetc_eatbnl() in more placesDenys Vlasenko2018-03-311-35/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * 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>
| * ash,hush: fix "saved" redirected fds still visible in childrenDenys Vlasenko2018-03-281-5/+11
| | | | | | | | | | | | | | | | | | | | 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>
* | ash: add some debug for the forkshell data blockRon Yorston2018-04-011-0/+87
| |
* | ash: align funcblocksize handling with upstreamRon Yorston2018-04-011-68/+76
| | | | | | | | | | | | Upstream BusyBox removed the global funcblocksize variable. Instead a local variable with the same name is passed to and returned from all functions that calculate item sizes. Do the same here.
* | ash: align funcstring handling with upstreamRon Yorston2018-04-011-27/+30
| | | | | | | | | | | | | | | | | | Upstream BusyBox removed the funcstringsize variable. String sizes are included in funcblocksize then strings are copied into the data block starting from the end. Do the same here. Add a function to calculate string lengths, allowing for NULL string pointers (as nodeckstrup does already for MinGW).
* | ash: reorder items in forkshell data blockRon Yorston2018-04-011-48/+47
| | | | | | | | | | | | Put the nodeptr array before funcblock and funcstring. Since nodeptr now immediately follows the forkshell structure in the data block we can declare it in the structure and do away with nodeptr_offset.