aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
| * placate gcc 8.0.1 sprintf overflow warnings in config toolsDenys Vlasenko2018-04-051-1/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix a few more corner cases with empty-expanding `cmds`Denys Vlasenko2018-04-055-8/+46
| | | | | | | | | | | | | | | | | | See added testcases function old new delta run_pipe 1723 1784 +61 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix corner cases with exec in empty expansionsDenys Vlasenko2018-04-055-17/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cases like these: var=val exec >redir var=val `` >redir function old new delta run_pipe 1701 1723 +22 redirect_and_varexp_helper 56 55 -1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 22/-1) Total: 21 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: less mind-bending set_vars_and_save_old()Denys Vlasenko2018-04-051-71/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta run_pipe 1651 1701 +50 set_local_var 510 557 +47 pseudo_exec_argv 544 581 +37 redirect_and_varexp_helper 64 56 -8 set_vars_and_save_old 164 149 -15 unset_local_var 274 256 -18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/3 up/down: 134/-41) Total: 93 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: "no logic changes" in last commit was not true, fix it upDenys Vlasenko2018-04-051-1/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: make run_pipe code simpler to understand, no logic changesDenys Vlasenko2018-04-051-66/+57
| | | | | | | | | | | | | | function old new delta run_pipe 1641 1651 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix a bug where we don't properly handle f() { a=A; b=B; }; a= fDenys Vlasenko2018-04-055-82/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta unset_local_var 20 274 +254 leave_var_nest_level - 98 +98 set_vars_and_save_old 128 164 +36 enter_var_nest_level - 32 +32 builtin_local 46 50 +4 pseudo_exec_argv 554 544 -10 redirect_and_varexp_helper 77 64 -13 run_pipe 1890 1641 -249 unset_local_var_len 267 - -267 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 3/3 up/down: 424/-539) Total: -115 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: make var nesting code independent of "local" supportDenys Vlasenko2018-04-041-40/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, add code to abort at ~65000 function recursion depth. SEGVing is not as nice as exiting with a message (and restoring termios!): $ f() { echo -n .; f; }; f ....<many dots later>....hush: fatal recursion (depth 65281) function old new delta run_pipe 1826 1890 +64 pseudo_exec_argv 544 554 +10 parse_and_run_file 71 80 +9 i_getch 104 107 +3 done_command 99 102 +3 set_local_var 508 510 +2 helper_export_local 214 215 +1 builtin_local 49 46 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 7/1 up/down: 92/-3) Total: 89 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix for readonly vars in "ro=A ro=B cmd" caseDenys Vlasenko2018-04-043-13/+21
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sort: move misplaced commentDenys Vlasenko2018-04-041-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sort: FEATURE_SORT_OPTIMIZE_MEMORYDenys Vlasenko2018-04-041-6/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | On sorting all kernel/linux/arch/ *.[ch] files, this reduces memory usage by 6%. yes | head -99999999 | sort goes down from 1900Mb to 380 Mb. function old new delta sort_main 862 1098 +236 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>
| * 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>
* | libarchive: failure to extract symlink isn't fatalRon Yorston2018-04-092-1/+13
| | | | | | | | | | | | | | | | Recent upstream changes made the failure of symlink(2) when extracting from an archive a fatal error. The busybox-w32 implementation of symlink(2) always fails. Just issue a warning and move on.
* | win32: more backslash to slash conversionsRon Yorston2018-04-082-1/+5
| | | | | | | | | | | | | | | | | | 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.
* | pipe_progress: add help textRon Yorston2018-04-081-2/+4
| |
* | win32: don't leak pipe data structuresRon Yorston2018-04-071-58/+66
| | | | | | | | | | | | | | | | | | | | | | | | popen uses an array of pipe_data structures to record information that's later used by pclose. pclose releases the structure after use. The lower-level pipe function mingw_popen_fd was also using this array of structures but didn't provide any way to release them. Avoid this leak by letting mingw_popen_fd use a local structure instead.
* | ps: indicate forkshell processes in listingRon Yorston2018-04-052-4/+5
| |
* | win32: exclude termios codeRon Yorston2018-04-056-21/+26
| | | | | | | | | | The code to manipulate terminal settings serves no purpose in WIN32. Use conditional compilation to exclude much of it.
* | vi: turn off FEATURE_VI_ASK_TERMINAL in the default configurationRon Yorston2018-04-052-2/+2
| |
* | ash: emulate raw input to read builtinRon Yorston2018-04-051-2/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | Use read_key to emulate raw input when reading from the console. Limit this to cases where raw input is necessary: - a maximum number of characters is to be read (-n) - a timeout has been specified (-t) - a non-standard delimiter is in use (-d) This should fix GitHub issue #112 (and other things too!). Also, omit sections of code that serve no purpose on WIN32.
* | win32: ensure timeout works in read_keyRon Yorston2018-04-051-4/+4
| | | | | | | | | | | | Move the wait for timeout into the while loop of read_key. Otherwise the timeout won't be checked after any event that doesn't result in a value being returned.
* | ps: obtain applet names from other BusyBox processesRon Yorston2018-04-046-42/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | fsync: avoid a gratuitous difference from upstreamRon Yorston2018-04-032-3/+1
| | | | | | | | | | Move the definition of O_NOCTTY to mingw.h so that fsync.c is the same as upstream.
* | ttysize: enable in default configurationRon Yorston2018-04-032-2/+2
| | | | | | | | | | | | | | | | | | | | Previously $ HEIGHT=$(ttysize h) would always return a default height of 24 because stdout wasn't connected to a console. Now that get_terminal_width_height also checks stderr the above works.
* | win32: improvements to get_terminal_width_heightRon Yorston2018-04-034-20/+25
| | | | | | | | | | | | | | | | - move winansi_get_terminal_width_height from winansi.c to ioctl.c, the only caller; - check both stdout and stderr for a connection to a console; - omit unnecessary code in get_terminal_width_height (because the WIN32 implementation ignores the file descriptor).
* | win32: simplify isatty replacementRon Yorston2018-04-031-5/+1
| | | | | | | | | | Don't treat input and output file descriptors differently: if we aren't connected to a console GetConsoleMode will fail for either.
* | ash: reinstate applet name variable after forkshellRon Yorston2018-04-033-6/+16
| | | | | | | | | | | | 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.
* | Update default configurationsRon Yorston2018-04-022-2/+4
| |
* | Merge branch 'busybox' into mergeRon Yorston2018-04-0270-187/+799
|\|
| * 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>