summaryrefslogtreecommitdiff
path: root/shell (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
| * 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>
| * 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>
* | 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.
* | ash: revise handling of builtin environment variables during forkRon Yorston2018-03-311-32/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit db03ff5ea made some improvements to the handling of builtin environment variables during forkshell. However, more can be done. Currently the calculated size of varinit doesn't match what's actually copied. It overestimates the amount of string space and the number of pointers. The text of each builtin environment variable is also copied twice: once as part of vartab and again from varinit. Remove the code to copy varinit via the forkshell block. Instead use information from vartab and varinit_data to reinitialise varinit and fix the links in vartab. In addition, ensure that the LINENO variable is properly initialised in the child.
* | ash: copy environment variables when importing themRon Yorston2018-03-301-0/+4
| | | | | | | | | | | | | | | | | | Clearing the environment on Microsoft Windows results in pointers used for shell variables becoming invalid. Take copies when the environment is imported. This only affects NOFORK applets invoked by tryexec, but the number of NOFORK applets has increased considerably in recent years.
* | ash: use SIGTERM to kill processesRon Yorston2018-03-271-1/+9
| | | | | | | | | | When Ctrl-C is pressed try killing processes with SIGTERM initially. If they're still running after a short pause use sterner measures.
* | win32: allow use of shell's PRNG for /dev/urandomRon Yorston2018-03-223-0/+15
| | | | | | | | | | | | Allow either ISAAC or the shell's built-in pseudo-random number generator to be used for /dev/urandom. The latter is smaller so it's the default.
* | win32: add a function to convert backslashes to slashesRon Yorston2018-03-181-6/+2
| |
* | ash: remove special treatment of device filesRon Yorston2018-03-151-20/+0
| | | | | | | | | | Since device files are now handled in mingw_open there's no need for any special treatment in ash redirection.
* | Merge branch 'busybox' into mergeRon Yorston2018-03-1522-11/+137
|\|
| * hush: code shrinkDenys Vlasenko2018-03-061-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta run_pipe 1589 1591 +2 pseudo_exec_argv 374 375 +1 builtin_type 114 115 +1 find_function 8 - -8 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 3/0 up/down: 4/-8) Total: -4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix a='a\\'; echo "${a%\\\\}"Denys Vlasenko2018-03-0210-3/+39
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: tweak bkslash_in_varexp.tests, add bkslash_in_varexp1.testsDenys Vlasenko2018-03-028-5/+50
| | | | | | | | | | | | | | | | | | It turns out bkslash_in_varexp.tests was a bash bug :] ash and hush fail "corrected" bkslash_in_varexp.tests as well, just not as badly as I thought (hush gets half of the cases right). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: two new tests, both fail for ash and hushDenys Vlasenko2018-03-028-0/+44
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2018-03-016-17/+122
|\|
| * hush: simplify process_command_subs()Denys Vlasenko2018-02-131-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Incidentally, this fixes LINENO bug here: echo "1:${LINENO}" echo "2:`echo; echo`" # was counting lines in the `cmd` output as LINENO++ echo "3:${LINENO}" function old new delta parse_and_run_file 53 71 +18 expand_vars_to_list 1187 1164 -23 setup_file_in_str 25 - -25 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/1 up/down: 18/-48) Total: -30 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash : fix double-quoted "\z" handlingDenys Vlasenko2018-02-135-6/+113
| | | | | | | | | | | | | | function old new delta readtoken1 2602 2608 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Remove fake signal-handling codeRon Yorston2018-03-011-3/+10
| | | | | | | | | | | | | | | | | | Microsoft Windows has only limited support for signals. busybox-w32 initially papered over this fact by adding definitions for unsupported signals and signal-handling functions. Remove this fake code and deal with the consequences by excluding anything that fails to compile as a result.
* | ash: changes to command resolution, execution and displayRon Yorston2018-02-281-23/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ash separates searching for commands from running them. Searching is performed in find_command(). The result of the search is stored in a hash table but not as the full path: the path is reconstructed in shellexec() by combining the directory and command name. In Windows the command name is insufficient, as the executable name may also include an extension. To resolve this we must ensure that extensions are processed in the same order in find_command, shellexec and any other places where command names are resolved into file names. The order used matches that of spawnve: .com, .exe, .bat, .cmd. Finally the bare filename with no additional extension The order has been made consistent: - in find_command for absolute paths and the Windows-specific path search; - in tryexec (which is called by shellexec) where an additional test that the file is executable has been added; - in the type and hash built-ins where the output has been modified to include the extension. Additionally, the code in tryexec to handle ENOEXEC errors from execve has been excluded. The rationale for the exec functions in POSIX [1] suggests the requirement to retry is a workaround for the lack of '#!' support on some platforms. [1] http://pubs.opengroup.org/onlinepubs/009695399/functions/exec.html
* | win32: move detection of file formats to stat(2)Ron Yorston2018-02-261-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the code to detect shell scripts and binary executables from mingw_access to a separate function, has_exec_format. Call this function in do_lstat to decide whether to set the executable bits in the file mode. This will slow down stat but has a couple of advantages: - shell scripts are highlighted in ls output - the test applet can use stat(2) to detect executable files The new function is used to handle another corner case in spawnveq: binary executables without the usual .exe extension are only run by spawnve if the file name ends with '.'. Two minor changes: - file_is_win32_executable has been renamed add_win32_extension to clarify what it does - a call to file_is_executable has been removed from find_command in ash as it resulted in unhelpful error messages.
* | win32: add support for batch filesRon Yorston2018-02-261-18/+22
| | | | | | | | | | | | | | | | Support batch files with .bat and .cmd extensions, similar to what's done for .exe and .com. Check extensions in the same order as Windows' spawn function: .com, .exe, .bat, .cmd.
* | ash: tidy up /dev/null redirectionRon Yorston2018-02-221-11/+6
| | | | | | | | | | Remove some duplicated code and raise an error for unsupported devices.
* | ash: use correct size for tblentryRon Yorston2018-02-191-2/+2
| | | | | | | | | | | | | | | | | | | | As noted in cmdlookup the size of a tblentry instance, *t, is sizeof(struct tblentry) + strlen(t->cmdname) because the structure includes one byte for the cmdname array. Apply the same logic in tblentry_size and tblentry_copy.
* | ash: allow waitpid_child to blockRon Yorston2018-02-171-1/+1
| | | | | | | | | | The wrong sort of boolean operator resulted in waitpid_child always being nonblocking.
* | Merge branch 'busybox' into mergeRon Yorston2018-02-1342-684/+696
|\|
| * hush: probably fixing a bug in last LINENO fixDenys Vlasenko2018-02-081-11/+6
| | | | | | | | | | | | | | | | | | | | I don't have an example of mishandled script, but the logic looked wrong: it could sometimes treat newlines as if they are spaces. function old new delta parse_stream 2788 2787 -1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: LINENO fixDenys Vlasenko2018-02-081-24/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Script triggering the bug: t=0 echo "at line ${LINENO}" while [ ${t} -lt 10 ]; do echo "at line ${LINENO}" # LINENO was 3 instead of 4 here t=$((t+1)) done function old new delta parse_stream 2754 2788 +34 done_word 711 738 +27 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 61/0) Total: 61 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: protect against self-modifying trap codeDenys Vlasenko2018-01-301-1/+3
| | | | | | | | | | | | | | function old new delta check_and_run_traps 211 236 +25 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: make it possible to disable "const global ptr" optimizationDenys Vlasenko2018-01-281-3/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: handle $((NUM++...) like bash does. Closes 10706Denys Vlasenko2018-01-289-14/+57
| | | | | | | | | | | | | | function old new delta evaluate_string 680 729 +49 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: add LINENO supportDenys Vlasenko2018-01-274-534/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is a backport from dash of the combination of: [SHELL] Add preliminary LINENO support [VAR] Fix varinit ordering that broke fc [SHELL] Improve LINENO support function old new delta parse_command 1604 1677 +73 calcsize 156 223 +67 copynode 196 258 +62 evalcommand 1546 1606 +60 ash_main 1046 1103 +57 lookupvar 51 106 +55 evalcase 269 317 +48 evaltree 501 547 +46 evalfor 156 200 +44 evalsubshell 156 195 +39 raise_error_syntax 11 29 +18 varinit_data 120 132 +12 evalfun 270 280 +10 funcline - 4 +4 cmdtxt 569 572 +3 trapcmd 306 304 -2 ash_vmsg 153 150 -3 startlinno 4 - -4 funcnest 4 - -4 xxreadtoken 263 250 -13 readtoken1 2645 2602 -43 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 14/4 up/down: 598/-69) Total: 529 bytes text data bss dec hex filename 932834 481 6864 940179 e5893 busybox_old 933375 481 6856 940712 e5aa8 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: add HUSH_BASH_SOURCE_CURDIR config option, to be on par with ashDenys Vlasenko2018-01-272-3/+10
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix dot builtin to not search current directoryDenys Vlasenko2018-01-271-0/+5
| | | | | | | | | | | | | | function old new delta builtin_source 182 209 +27 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: introduce a config option to search current directory for sourced filesDenys Vlasenko2018-01-261-1/+12
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash testsuite: add two hush tests from last commitDenys Vlasenko2018-01-254-0/+10
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix two corner cases in ${v/pattern/repl}. Closes 10686Denys Vlasenko2018-01-255-2/+21
| | | | | | | | | | | | | | function old new delta expand_one_var 1592 1618 +26 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix handling of $_ (so far it's an ordinary variable, no special meaning)Denys Vlasenko2018-01-251-10/+17
| | | | | | | | | | | | | | function old new delta parse_dollar 820 779 -41 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: add support for command_not_found_handle hook function (bashism)William Pitcock2018-01-241-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements support for the command_not_found_handle hook function, which is useful for allowing package managers to suggest packages which could provide the command. Unlike bash, however, we ignore exit codes from the hook function and always return the correct POSIX error code (EX_NOTFOUND). function old new delta find_command 911 990 +79 Signed-off-by: William Pitcock <nenolod@dereferenced.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix a case where EXIT trap may modify its code mid-flightDenys Vlasenko2018-01-191-1/+1
| | | | | | | | | | | | | | function old new delta hush_exit 93 99 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix build if !BASH_LINENO_VARDenys Vlasenko2018-01-191-8/+13
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: implement $LINENO bashismDenys Vlasenko2018-01-193-2/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta run_pipe 1697 1774 +77 unset_local_var_len 258 301 +43 hush_main 1009 1051 +42 set_local_var 516 554 +38 parse_and_run_file 42 75 +33 i_getch 96 116 +20 .rodata 18858 18876 +18 done_command 106 122 +16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 8/0 up/down: 287/0) Total: 287 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: a bit of NOFORK code should only be active if FEATURE_SH_STANDALONE=yDenys Vlasenko2018-01-151-1/+3
| | | | | | | | | | | | | | function old new delta evalcommand 1546 1420 -126 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: echo ${?:0} was fixed sometime ago, enable it in testsDenys Vlasenko2018-01-134-2/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>