aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge branch 'busybox' into mergeRon Yorston2017-11-031-21/+84
|\|
| * ash: fix nofork bug where environment is not properly passed to a commandDenys Vlasenko2017-11-031-5/+40
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta listvars 144 252 +108 evalcommand 1500 1546 +46 showvars 142 147 +5 shellexec 242 245 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 162/0) Total: 162 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: retain envvars with bad names in initial environment. Closes 10231Denys Vlasenko2017-11-021-4/+22
| | | | | | | | | | | | | | Reworks "ash: [VAR] Sanitise environment variable names on entry" commit. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * whitespace fixesDenys Vlasenko2017-10-121-3/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * typo fixDenys Vlasenko2017-10-121-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: survive failures in $PS1 expansion. Closes 10371Denys Vlasenko2017-10-121-1/+18
| | | | | | | | | | | | | | function old new delta expandstr 120 209 +89 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * use %m printf specifier where appropriateDenys Vlasenko2017-09-291-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta out 85 75 -10 udhcpd_main 1472 1461 -11 open_stdio_to_tty 98 85 -13 init_exec 245 232 -13 udhcpc_main 2763 2749 -14 do_cmd 4771 4755 -16 status_line_bold_errno 32 14 -18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-95) Total: -95 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2017-09-271-7/+7
|\|
| * ash: more s/error/perror/ for better error reportingDenys Vlasenko2017-08-231-5/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: when cd fails, say whyJohannes Schindelin2017-08-231-1/+1
| | | | | | | | | | Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: report reason when a script file could not be openedJohannes Schindelin2017-08-231-1/+1
| | | | | | | | | | | | | | | | It is always nicer to give the user some sort of indication why an operation failed. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: stop assuming that pointers and ints are interchangeableJohannes Schindelin2017-08-311-3/+3
| | | | | | | | | | | | | | | | This is a companion patch to db169a143 (win32: ash: forkshell_init(), 2010-04-14). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Ron Yorston <rmy@pobox.com>
* | ash: avoid assumption about sizeof(long) == sizeof(void *)Johannes Schindelin2017-08-311-1/+1
| | | | | | | | | | | | | | | | This change fixes a minor bug in eea918c5e (win32: ash: spawn_forkshell(), 2010-04-14). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Ron Yorston <rmy@pobox.com>
* | win32: shrink code to detect .exe filesRon Yorston2017-08-301-9/+4
| | | | | | | | | | | | | | | | Add a function (has_exe_suffix) to replace explicit code to check if a filename ends with '.exe. or '.com'. Also shrink code that checks for '.exe' or '.com' on PATH in shell's find_command function.
* | Revert "ash: allow long-running nofork applets to be interrupted"Ron Yorston2017-08-221-9/+1
| | | | | | | | | | | | | | This reverts commit f5051d07f196a8ff7aeaae762333d5aa2b824088. Upstream made 'yes' and 'seq' NOEXEC rather than NOFORK which also solves the problem, though NOEXEC doesn't provide any gain in busybox-w32.
* | Merge branch 'busybox' into mergeRon Yorston2017-08-221-42/+110
|\|
| * ash: unset OPTARG if getopts exits 1, support OPTERR=0 behaviorDenys Vlasenko2017-08-151-2/+11
| | | | | | | | | | | | | | function old new delta getoptscmd 522 547 +25 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash,hush: comment and debug tweaks, no code changesDenys Vlasenko2017-08-151-2/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: one "current line = 1" might be missing, fix thatDenys Vlasenko2017-08-141-4/+5
| | | | | | | | | | | | | | I'm not sure this is necessary, but dash has this init here. Just in case, do it too. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [PARSER] Catch variable length expansions on non-existant specialsDenys Vlasenko2017-08-141-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 30 Oct 2014 11:53:35 +0800 [PARSER] Catch variable length expansions on non-existant specials Currently we only check special variable names that follow directly after $ or ${. So errors such as ${#&} are not caught. This patch fixes that by moving the is_special check to just before we print out the special variable name. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> function old new delta readtoken1 2630 2635 +5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: fix "unset OPTIND" throwing an error messageDenys Vlasenko2017-08-111-1/+3
| | | | | | | | | | | | | | Added test was failing quite severely. Now only one subtest fails (OPTERR=0 has no effect). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: optional times builtinDenys Vlasenko2017-08-101-7/+9
| | | | | | | | | | | | | | | | | | | | | | function old new delta builtin_times - 108 +108 bltins1 360 372 +12 static.times_tbl - 9 +9 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 1/0 up/down: 129/0) Total: 129 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: implement -d DELIM option for readJohannes Schindelin2017-08-091-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The POSIX standard only requires the read builtin to handle -r: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html However, Bash introduced the option -d <DELIM> to override IFS for just one invocation, and it is quite useful. It is also super easy to implement in BusyBox' ash, so let's do that. The motivation: This option is used by Git's test suite. function old new delta .rodata 163505 163587 +82 shell_builtin_read 1244 1289 +45 readcmd 233 259 +26 builtin_read 258 263 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 158/0) Total: 158 bytes Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * noexec: consolidate codeDenys Vlasenko2017-08-071-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta run_noexec_applet_and_exit - 61 +61 find_applet_by_name 128 124 -4 run_applet_no_and_exit 441 434 -7 tryexec 169 152 -17 pseudo_exec_argv 338 321 -17 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/6 up/down: 61/-48) Total: 13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * noexec: do GETOPT_RESET() before entering APPLET_main()Denys Vlasenko2017-08-071-0/+1
| | | | | | | | | | | | | | | | | | | | hush -c 'yes | head -1' was not happy. function old new delta tryexec 159 169 +10 pseudo_exec_argv 328 338 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * noexec: set comm field for noexecsDenys Vlasenko2017-08-071-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta set_task_comm - 18 +18 tryexec 152 159 +7 pseudo_exec_argv 321 328 +7 main 106 97 -9 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/2 up/down: 34/-13) Total: 23 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * free,stat: make NOEXECDenys Vlasenko2017-08-071-0/+2
| | | | | | | | | | | | pkill/pgrep/pidof uncovered another quirk: what about noexec's _process names_? Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: do not set a signal to SIG_DFL if it already isDenys Vlasenko2017-08-061-1/+7
| | | | | | | | | | | | | | function old new delta setsignal 312 338 +26 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: BASH_XTRACEFD bashismDenys Vlasenko2017-08-041-0/+10
| | | | | | | | | | | | | | | | | | Based on patch by Johannes Schindelin <johannes.schindelin@gmx.de> function old new delta evalcommand 1447 1500 +53 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: remove no-longer-used variableJohannes Schindelin2017-08-041-2/+0
| | | | | | | | | | | | | | | | | | | | | | As of 035486c75 (ash: significant overhaul of redirect saving logic, 2017-07-31), the sv_pos variable is no longer used (just assigned to, with no further effect). Let's just remove it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: INT_OFF/INT_ON around run_nofork_applet()Denys Vlasenko2017-08-041-3/+19
| | | | | | | | | | | | | | function old new delta evalcommand 1441 1447 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sheel: improve comments on signal handlingDenys Vlasenko2017-08-041-11/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: add a fixme comment at run_nofork_appletDenys Vlasenko2017-08-031-1/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * line editing: make read_line_input() not take timeout paramDenys Vlasenko2017-08-021-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's almost always -1. function old new delta read_line_input 3902 3912 +10 new_line_input_t 24 31 +7 pgetc 583 585 +2 save_command_ps_at_cur_history 80 78 -2 read_line 76 74 -2 fgetc_interactive 246 244 -2 addLines 84 82 -2 doCommands 2226 2222 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/5 up/down: 19/-12) Total: 7 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * do not use `a' quoting style in commentsDenys Vlasenko2017-08-021-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: improvements to ctrl-c handlingRon Yorston2017-08-031-1/+4
| | | | | | | | | | | | | | | | | | | | Setting pending_int *before* hSIGINT improves the behaviour when interrupting a shell script. Echo '^C' to the console when handling an interrupt. Increment shlvl in forkshell_init. On non-WIN32 platforms this was done in forkchild.
* | ash: fixes to wait statusRon Yorston2017-08-031-2/+2
| | | | | | | | | | Replace W* macros with versions from GNU C library. Change wait status values to match.
* | Merge branch 'busybox' into mergeRon Yorston2017-08-021-302/+393
|\|
| * ash: align --login code with dashDenys Vlasenko2017-07-311-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Sun, 13 Jul 2008 22:34:50 +0800 [OPTIONS] Added support for -l This patch adds support for the -l option (login shell) as required by the LSB. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> It's a bit bigger, but gets rid of one global variable function old new delta options 554 576 +22 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: fix display of ">&-" redirect in job stringsDenys Vlasenko2017-07-311-1/+8
| | | | | | | | | | | | | | function old new delta cmdtxt 558 569 +11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash,hush: ">&10" redirects to script/tty fds should not workDenys Vlasenko2017-07-311-9/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fact that shell has open fds to tty and/or scripts should be unobservable, if possible. In particular, if redirect tries to dup one of them via ">&script_fd", it's better to pretend that script_fd is closed, and thus redirect fails with EBADF. Fixes these two testcase failures: ash-redir/redir_to_bad_fd.tests hush-redir/redir_to_bad_fd3.tests function old new delta redirect 1018 1129 +111 setup_redirects 250 359 +109 readtoken1 2651 2655 +4 cmdloop 185 187 +2 changepath 194 195 +1 save_fd_on_redirect 203 194 -9 evaltree 501 484 -17 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/2 up/down: 227/-26) Total: 201 bytes text data bss dec hex filename 914553 485 6848 921886 e111e busybox_old 914754 485 6848 922087 e11e7 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: significant overhaul of redirect saving logicDenys Vlasenko2017-07-311-139/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New code is similar to what hush is doing. Make CLOSED to -1: same as dash. popredir() loses "restore" parameter: same as dash. COPYFD_RESTORE bit is no longer necessary. This change fixes this interactive bug: $ ls -l /proc/$$/fd 10>&- ash: can't set tty process group: Bad file descriptor ash: can't set tty process group: Bad file descriptor [1]+ Done(2) ls -l /proc/${\$}/fd 10>&4294967295 function old new delta unwindredir 29 27 -2 tryexec 154 152 -2 evaltree 503 501 -2 evalcommand 1369 1367 -2 cmdloop 187 185 -2 redirect 1029 1018 -11 popredir 153 123 -30 need_to_remember 36 - -36 is_hidden_fd 68 - -68 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 0/7 up/down: 0/-155) Total: -155 bytes text data bss dec hex filename 914572 485 6848 921905 e1131 busybox_old 914553 485 6848 921886 e111e busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: remove REDIR_SAVEFD2Denys Vlasenko2017-07-311-32/+37
| | | | | | | | | | | | | | | | | | | | function old new delta evalcommand 1364 1369 +5 redirect 1055 1014 -41 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 5/-41) Total: -36 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: if !ENABLE_ASH_EXPAND_PRMT, disable PSSYNTAX codeDenys Vlasenko2017-07-291-2/+8
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [REDIR] Fix popredir on abnormal exit from built-inDenys Vlasenko2017-07-291-26/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 27 May 2010 15:03:46 +0800 [REDIR] Fix popredir on abnormal exit from built-in Just like the poplocalvar problem recently fixed, redirections can also be leaked in case of an abnormal exit. This patch fixes it using the same method as poplocalvar, by storing the previous redirection state and restoring to that point. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [PARSER] Add FAKEEOFMARK for expandstrDenys Vlasenko2017-07-291-19/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: Date: Thu, 27 Dec 2007 13:54:16 +1100 [PARSER] Add FAKEEOFMARK for expandstr Previously expandstr used the string "" to indicate that it needs to be treated just like a here-doc except that there is no terminator. However, the string "" is in fact a valid here-doc terminator so now that we deal with it correctly expandstr no longer works in the presence of new-lines in the prompt. This patch introduces the FAKEEOFMARK macro which does not equal any real EOF marker but is distinct from the NULL pointer which is used to indicate non-here-doc contexts. Thanks to Markus Triska for reporting this regression. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Unfortunately, I did not find the failing example for this old fix. I also tweaked the code which was added by this commit: " Date: Mon Sep 24 18:30:02 2007 +0000 ash: fix prompt expansion (Natanael Copa <natanael.copa@gmail.com>) " since other parts of code do expect expandstr() to use DQSYNTAX, not PSSYNTAX. function old new delta parse_stream 2609 2634 +25 setprompt_if 128 133 +5 read_profile 32 37 +5 evalcommand 1334 1339 +5 expandstr 122 120 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 40/-2) Total: 38 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: [PARSER] Removed noexpand/length check on eofmarkDenys Vlasenko2017-07-291-70/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream comment: Date: Sun, 11 Nov 2007 14:21:23 +0800 [PARSER] Removed noexpand/length check on eofmark On Tue, Oct 30, 2007 at 04:23:35AM +0000, Oleg Verych wrote: > > } 8<<"" > ====================== Actually this (the empty delim) only works with dash by accident. I've tried bash and pdksh and they both terminate on the first empty line which is what you would expect rather than EOF. The real Korn shell does something completely different. I've fixed this in dash to conform to bash/pdksh. > In [0] it's stated, that delimiter isn't evaluated (expanded), only > quoiting must be checked. That if() seems to be completely bogus. OK I agree. The reason it was there is because the parser would have already replaced the dollar sign by an internal representation. I've fixed it properly with this patch. Test case: cat <<- $a OK $a cat <<- "" OK echo OK Old result: dash: Syntax error: Illegal eof marker for << redirection OK echo OK New result: OK OK OK function old new delta parsefname 227 152 -75 readtoken1 2819 2651 -168 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-243) Total: -243 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: "Undo all redirections" comment is wrong, delete itDenys Vlasenko2017-07-291-26/+22
| | | | | | | | | | | | No code changes. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: don't reset pending_int in waitpid_childRon Yorston2017-08-021-1/+0
| | | | | | | | Testing on Windows 10 showed that to be a bad idea.
* | ash: allow long-running nofork applets to be interruptedRon Yorston2017-08-011-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Nofork applets can't be interrupted with ctrl-c. This isn't an issue for most such applets because they do very little and won't run for very long. However 'yes' and 'seq 10000000' can't be interrupted in a interactive shell, which is awkward. As a special case ignore the nofork-ness of these applets if they're run from an interactive shell. This isn't foolproof as there are still ways to run them such that they can't be interrupted, but it helps.