summaryrefslogtreecommitdiff
path: root/shell (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
| * shell: implement optional "BASE#nnnn" numeric literalsDenys Vlasenko2019-05-193-6/+51
| | | | | | | | | | | | | | function old new delta evaluate_string 729 851 +122 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: remove test for "echo ${-}" errorring out - now it worksDenys Vlasenko2019-05-193-4/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: implement $-, set default PATH if it is not set on startupDenys Vlasenko2019-05-191-5/+26
| | | | | | | | | | | | | | | | | | | | | | function old new delta expand_one_var 2311 2362 +51 hush_main 1075 1104 +29 parse_dollar 790 791 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 81/0) Total: 81 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: set default PS1/2 only if we interactiveDenys Vlasenko2019-05-191-16/+19
| | | | | | | | | | | | | | | | | | | | "env - hush SCRIPT" invocation (that is, with empty environment) should not show PS1/2 in "set" output. function old new delta hush_main 1070 1075 +5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: handle LINENO the same way as RANDOM: variable is "ephemeral"Denys Vlasenko2019-05-191-32/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "env - hush" invocation (that is, with empty environment) should not show LINENO in "set" output. function old new delta get_local_var_value 263 294 +31 hush_main 1105 1070 -35 handle_changed_special_names 79 38 -41 run_pipe 1834 1765 -69 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 31/-145) Total: -114 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: remove code to track PS1/2 values dynamically - it's too much workDenys Vlasenko2019-05-161-61/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Assignments / exports / unsets of variables are far more frequent than prompt printing, and if we show prompt, we are likely to be limited by user typing speed - do not optimize for that scenario. Just re-query $PS1 / $PS2 values when need to show the prompt. function old new delta fgetc_interactive 236 259 +23 set_vars_and_save_old 150 147 -3 pseudo_exec_argv 597 594 -3 hush_main 1110 1105 -5 enter_var_nest_level 38 32 -6 builtin_local 56 50 -6 run_pipe 1857 1834 -23 leave_var_nest_level 127 98 -29 handle_changed_special_names 111 79 -32 cmdedit_update_prompt 57 - -57 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/8 up/down: 23/-164) Total: -141 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: small speedup in handle_changed_special_names()Denys Vlasenko2019-05-161-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: add TODO comment about BASE#nnn literalsDenys Vlasenko2019-05-161-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix quoted "${notexist-}" expansion to not disappearDenys Vlasenko2019-05-155-0/+20
| | | | | | | | | | | | | | function old new delta expand_one_var 2296 2311 +15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shells: add tests for backslashes in export VAR=VALDenys Vlasenko2019-05-144-0/+6
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix "export PS1=xyz" and "local PS1=xyz" messing up promptDenys Vlasenko2019-05-143-32/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta helper_export_local 215 253 +38 leave_var_nest_level 107 127 +20 run_pipe 1840 1857 +17 handle_changed_special_names 101 105 +4 shell_builtin_read 1399 1398 -1 done_word 767 766 -1 parse_stream 2249 2245 -4 set_local_var 437 430 -7 is_well_formed_var_name 66 - -66 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 4/4 up/down: 79/-79) Total: 0 bytes text data bss dec hex filename 952376 485 7296 960157 ea69d busybox_old 952400 485 7296 960181 ea6b5 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash,hush: ulimit: add -i RLIMIT_SIGPENDING, -q RLIMIT_MSGQUEUEDenys Vlasenko2019-04-281-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta limits_tbl 104 120 +16 ulimit_opt_string 44 50 +6 limit_chars 14 16 +2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 24/0) Total: 24 bytes text data bss dec hex filename 981996 485 7296 989777 f1a51 busybox_old 982065 485 7296 989846 f1a96 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash,hush: bash compat for ulimit: reorder to matchDenys Vlasenko2019-04-281-72/+53
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash,hush: bash compat for ulimit: -w => -x, -p => -uDenys Vlasenko2019-04-271-12/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash,hush: fix ulimit to be more bash-compat, closes 11791Denys Vlasenko2019-04-271-84/+181
| | | | | | | | | | | | | | | | | | | | function old new delta shell_builtin_ulimit 486 651 +165 limit_chars - 14 +14 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 179/0) Total: 179 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeFRP-3128-g241d4d4acRon Yorston2019-04-202-16/+23
|\|
| * httpd: use full size of iobuf[] when piping CGI dataDenys Vlasenko2019-04-191-3/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: catch error in arithmetic expansion in PS1Ron Yorston2019-04-191-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Setting PS1 to: PS1='$((123+))' causes the shell to enter an infinite error loop: sh: arithmetic syntax error Catch any exception raised by expandarg() in expandstr() and allow processing to continue. function old new delta expandstr 262 344 +82 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 82/0) Total: 82 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: prevent error in backquotes in PS1 from exiting shellRon Yorston2019-04-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Setting PS1 to: PS1='`xxx(`' causes the shell to terminate with the error: sh: syntax error: unexpected end of file (expecting ")") This happens because old-style backquotes require the input to be reread and thus call setinputstring() a second time. Prevent the problem by unwinding all recently opened files in expandstr(). function old new delta unwindfiles - 22 +22 expandstr 247 262 +15 forkchild 631 625 -6 evalcommand 1694 1685 -9 ash_main 1346 1336 -10 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/3 up/down: 37/-25) Total: 12 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2019-04-172-20/+79
|\|
| * ash: add bash-compatible EPOCH variablesRon Yorston2019-04-161-21/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bash 5.0 added the dynamic variable EPOCHSECONDS and EPOCHREALTIME which return the number of seconds since the Unix Epoch as an integer or float. These are useful for logging or tracing. function old new delta change_epoch - 78 +78 .rodata 175167 175235 +68 varinit_data 264 312 +48 change_seconds - 24 +24 change_realtime - 24 +24 ------------------------------------------------------------------------------ (add/remove: 3/0 grow/shrink: 2/0 up/down: 242/0) Total: 242 bytes text data bss dec hex filename 938508 4203 1888 944599 e69d7 busybox_old 938702 4203 1888 944793 e6a99 busybox_unstripped v2: Cast tv_sec and tv_usec to unsigned quantities. Add brackets to macros. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: an unset dynamic variable should not be dynamicRon Yorston2019-04-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit b28d4c346 (ash: [VAR] Move unsetvar functionality into setvareq) dropped the code that caused dynamic variables to lose their special properties when unset. Add it back again. function old new delta setvareq 346 360 +14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 14/0) Total: 14 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: add bash-compatible EPOCH variablesRon Yorston2019-04-161-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bash 5.0 added the dynamic variable EPOCHSECONDS and EPOCHREALTIME which return the number of seconds since the Unix Epoch as an integer or float. These are useful for logging or tracing. function old new delta get_local_var_value 207 302 +95 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 95/0) Total: 95 bytes text data bss dec hex filename 938702 4203 1888 944793 e6a99 busybox_old 938797 4203 1888 944888 e6af8 busybox_unstripped Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2019-04-041-7/+8
|\|
| * ash: distinguish 'wait -n' from other bashismsRon Yorston2019-04-021-7/+8
| | | | | | | | | | | | | | | | Add a specific define to indicate which bash compatibility code implements 'wait -n'. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: try to make working directory names consistentRon Yorston2019-04-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Standardise the path names used for the current working directory by: - resolving with realpath(3); - making the drive name or host name uppercase. The first only really works for physical drives; results for mapped drives are patchy. The standardisation is applied in two places: - at the end of updatepwd() in ash; - when a symbolic link is resolved in mingw_chdir().
* | df: display origin of mapped driveRon Yorston2019-04-011-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When a drive is mapped to a network share or a path display the mapping in the 'Filesystem' column of df's output. Since this changes the mnt_fsname field of the mntent structure a slight alteration is needed to print_all_cwd() in ash. Revert the change in commit a8c63f25b that enabled FEATURE_DF_FANCY in the default configuration. None of the additional options is very useful. See GitHub issue #164.
* | Merge branch 'busybox' into mergeRon Yorston2019-03-312-9/+79
|\|
| * hush: fix "wait -n" to wait for a _job_, not a _process_Denys Vlasenko2019-03-271-9/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta checkjobs 163 183 +20 process_wait_result 449 463 +14 leave_var_nest_level 98 107 +9 enter_var_nest_level 32 38 +6 set_vars_and_save_old 147 150 +3 builtin_local 53 56 +3 builtin_wait 322 323 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 7/0 up/down: 56/0) Total: 56 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: add "wait -n" bashismDenys Vlasenko2019-03-271-6/+47
| | | | | | | | | | | | | | | | | | | | function old new delta waitcmd 205 288 +83 dowait 405 444 +39 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 122/0) Total: 122 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: add "wait -n" bashismDenys Vlasenko2019-03-261-1/+17
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: improved support for c:path path namesRon Yorston2019-03-301-29/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Microsoft Windows permits path names of the form 'c:path', without a path separator after the colon. The system records a current directory for each drive and the path is interpreted relative to that. Since Windows API calls understand 'c:path' path names many commands in busybox-w32 already work with them. This commit adds the following: - The 'cd' shell built-in interprets 'c:path' path names correctly. Previously it treated them as relative to the shell's concept of the current working directory, not the current directory of the specified drive. - The 'pwd' shell built-in takes the '-a' option to list the current directory for all drives. - 'c:path' path names are subject to tab-completion. Paths of the form 'c:path' don't work for mapped network drives or paths that have been associated with a drive using SUBST. See GitHub issue #147.
* | win32: interpret absolute paths as relative to %SYSTEMDRIVE%Ron Yorston2019-03-281-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BusyBox contains hardcoded references to absolute paths which are unique in the *nix world but on Microsoft Windows are interpreted as being on the current drive. To make these unique again consider them to be relative to %SYSTEMDRIVE%. Support this by adding functions to: - determine the system drive (not using the environment variable); - change a process's current directory to the root of the system drive; - make relative paths absolute before changing directory (if needed). The following applications have been modified: - ash references /etc/profile from the system drive; - dpkg places its data store on and installs files to the system drive; - rpm installs files to the system drive; - man looks for configuration files and man pages on the system drive. See GitHub issue #158.
* | win32: share code to find root prefix of pathRon Yorston2019-03-231-28/+2
| | | | | | | | | | | | | | Move unc_root_len() from ash to mingw32.c and use it in the new function root_len(), which can be used in make_directory(). This reduces changes to upstream code and saves a few bytes.
* | ash: rewrite PATH update to save a few bytesRon Yorston2019-03-181-12/+8
| |
* | ash: enforce ';' separator in CDPATH and MANPATH variablesRon Yorston2019-03-161-11/+23
| | | | | | | | | | | | | | | | | | | | Commit a23624237 (win32: special treatment for PATH) required the PATH variable to use ';' as the separator between components and enforced this by intercepting attempts to update it. Do the same for the CDPATH and MANPATH variables. Also, fix a case in cdcmd() where the wrong separator was used.
* | ash: set current working directory on startupRon Yorston2019-03-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | When the shell starts behave as though the user had manually changed to the current working directory of the process, but only if it's an interactive, non-login shell and the '-d' flag isn't present. This gives more consistent behaviour when the shell is started in a drive mapped to a network share or a symlinked directory. This completes the changes requested in GitHub issue #148.
* | win32: add function to convert slashes to backslashesRon Yorston2019-03-151-2/+2
| | | | | | | | | | | | | | | | | | There are now two places where slashes are converted to backslashes throughout a string so it makes sense to create a function to do this. To avoid confusion rename convert_slashes() to bs_to_slash() and call the new function slash_to_bs().
* | Merge branch 'busybox' into mergeRon Yorston2019-03-121-10/+4
|\|
| * ash: eval: avoid leaking memory associated with redirections. Closes 7748Ron Yorston2019-02-251-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following constructs result in ever-increasing memory usage: while true; do { true; } </dev/null; done while true; do ( true; ) </dev/null; done For comparison, bash displays static memory usage in both cases. This has been fixed in dash by commit 2bc6caa. The maintainer writes: I have simplified evaltree so that it simply sets the stack mark unconditionally. This allows us to remove the stack marks in the functions called by evaltree. Closes BusyBox bug 7748. function old new delta evaltree 606 632 +26 evalcommand 1724 1696 -28 evalcase 382 351 -31 evalfor 230 196 -34 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 26/-93) Total: -67 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: improve handling of UNC pathsRon Yorston2019-03-111-8/+35
| | | | | | | | | | | | | | | | | | | | | | Rework the code in updatepwd() which processes UNC paths so that the root of a share is properly identified. This fixes problems when: - the current directory is a share and the user changes to '/'; - the current directory is the root of a share and the user tries to change to '..'.
* | win32: changes to user idsRon Yorston2019-03-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Formalise the use of 0 as the uid of a process running with elevated privileges: - Rewrite getuid(2) to return DEFAULT_UID by default and 0 if the process has elevated privileges. - geteuid(2) and the corresponding functions for groups are aliases for getuid(2). - Change root's home directory to be whatever GetSystemDirectory() returns, probably C:/Windows/System32 in most cases. - Remove the special handling of geteuid(2) in the line editing code. With these changes the shell started by 'su' is a lot more like a *nix root shell.
* | su: change title of console windowRon Yorston2019-03-091-1/+13
| |
* | ash, su: add -d flag to set directory in ash, use it in suRon Yorston2019-03-081-3/+30
| | | | | | | | | | | | | | | | When busybox-w32 is installed in C:/Windows/System32 su doesn't run in the same directory as its parent as intended. Work around this by adding a flag to the shell to set the working directory.
* | ash: add an option to enable case-insensitive filename globbingRon Yorston2019-03-011-4/+26
| | | | | | | | | | The 'nocaseglob' shell option enables case-insensitive filename globbing. By default globbing is case-sensitive.
* | win32: fix POSIX buildRon Yorston2019-02-171-0/+14
| | | | | | | | | | | | There were a few places where changes intended for the WIN32 build also affected the POSIX build. Fix these so the result of 'make defconfig; make' for busybox-w32 is identical to upstream BusyBox.
* | ash: updated support for hiding consoleRon Yorston2019-02-171-9/+3
| | | | | | | | | | | | | | | | Move the code to hide the console to a separate function in win32/mingw.c. Use lazy loading to avoid problems on platforms where the require APIs aren't supported (PR #70). Enable console hiding in the default 64-bit configuration.
* | ash: tidy up handling of -X optionRon Yorston2019-02-171-8/+7
| |
* | win32: add a function to remove CRs from a text bufferRon Yorston2019-02-141-10/+1
| |
* | ash: improve handling of 'read -t 0'Ron Yorston2019-02-081-4/+12
| | | | | | | | | | | | | | | | | | | | Instead of always returning that no input is available: - for a disk file return 'available'; - for the console return 'not available'; - for anything else (e.g. pipe) return whatever poll says. This fixes the test ash-read/read_t0.tests.