From 6a7524634e79519007ac61d8f0bc6f254118b7f4 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 16 Aug 2019 10:05:08 +0100 Subject: 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. --- shell/ash.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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[] = { "m" "monitor", "n" "noexec", /* Ditto: bash has no "set -s" */ +#if !ENABLE_PLATFORM_MINGW32 "s" "", +#else + "s" "stdin", +#endif "c" "", "x" "xtrace", "v" "verbose", @@ -14990,7 +14994,9 @@ procargs(char **argv) } if (iflag == 2 /* no explicit -i given */ && sflag == 1 /* -s given (or implied) */ +#if !ENABLE_PLATFORM_MINGW32 && !minusc /* bash compat: ash -sc 'echo $-' is not interactive (dash is) */ +#endif && isatty(0) && isatty(1) /* we are on tty */ ) { iflag = 1; @@ -15254,7 +15260,11 @@ int ash_main(int argc UNUSED_PARAM, char **argv) // ash -sc 'echo $-' // continue reading input from stdin after running 'echo'. // bash does not do this: it prints "hBcs" and exits. +#if !ENABLE_PLATFORM_MINGW32 evalstring(minusc, EV_EXIT); +#else + evalstring(minusc, sflag ? 0 : EV_EXIT); +#endif } if (sflag || minusc == NULL) { -- cgit v1.2.3-55-g6feb