aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-08-16 10:05:08 +0100
committerRon Yorston <rmy@pobox.com>2019-08-16 10:05:08 +0100
commit6a7524634e79519007ac61d8f0bc6f254118b7f4 (patch)
tree4f3bd774635a6d2b033a789f71424a5a2f2e4d71
parent517cf74f6265ec4308b790b637b3f9778cbdc6e0 (diff)
downloadbusybox-w32-6a7524634e79519007ac61d8f0bc6f254118b7f4.tar.gz
busybox-w32-6a7524634e79519007ac61d8f0bc6f254118b7f4.tar.bz2
busybox-w32-6a7524634e79519007ac61d8f0bc6f254118b7f4.zip
ash: revert change to behaviour of -s option
Upstream BusyBox commit f3634584d (ash,hush: show 'c' in $- if run in "sh -c CMD") changed the behaviour of -s to match that of bash rather than dash. This means that the -s and -c options can't be combined. This combination of options is used by the Windows 'su' applet to prevent the new console window from shutting down after the command has run. It's also useful when the shell is to be run with an initialisation command (GitHub issue #100). Revert the change so -s behaves as in dash.
-rw-r--r--shell/ash.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 690485a83..407a0304c 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -426,7 +426,11 @@ static const char *const optletters_optnames[] = {
426 "m" "monitor", 426 "m" "monitor",
427 "n" "noexec", 427 "n" "noexec",
428/* Ditto: bash has no "set -s" */ 428/* Ditto: bash has no "set -s" */
429#if !ENABLE_PLATFORM_MINGW32
429 "s" "", 430 "s" "",
431#else
432 "s" "stdin",
433#endif
430 "c" "", 434 "c" "",
431 "x" "xtrace", 435 "x" "xtrace",
432 "v" "verbose", 436 "v" "verbose",
@@ -14990,7 +14994,9 @@ procargs(char **argv)
14990 } 14994 }
14991 if (iflag == 2 /* no explicit -i given */ 14995 if (iflag == 2 /* no explicit -i given */
14992 && sflag == 1 /* -s given (or implied) */ 14996 && sflag == 1 /* -s given (or implied) */
14997#if !ENABLE_PLATFORM_MINGW32
14993 && !minusc /* bash compat: ash -sc 'echo $-' is not interactive (dash is) */ 14998 && !minusc /* bash compat: ash -sc 'echo $-' is not interactive (dash is) */
14999#endif
14994 && isatty(0) && isatty(1) /* we are on tty */ 15000 && isatty(0) && isatty(1) /* we are on tty */
14995 ) { 15001 ) {
14996 iflag = 1; 15002 iflag = 1;
@@ -15254,7 +15260,11 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
15254 // ash -sc 'echo $-' 15260 // ash -sc 'echo $-'
15255 // continue reading input from stdin after running 'echo'. 15261 // continue reading input from stdin after running 'echo'.
15256 // bash does not do this: it prints "hBcs" and exits. 15262 // bash does not do this: it prints "hBcs" and exits.
15263#if !ENABLE_PLATFORM_MINGW32
15257 evalstring(minusc, EV_EXIT); 15264 evalstring(minusc, EV_EXIT);
15265#else
15266 evalstring(minusc, sflag ? 0 : EV_EXIT);
15267#endif
15258 } 15268 }
15259 15269
15260 if (sflag || minusc == NULL) { 15270 if (sflag || minusc == NULL) {