From 6392ae0444fe13ea0e62021247bf0dcab5bc7f23 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 24 May 2013 15:56:07 +0100 Subject: ash: add noconsole option to hide console window on WIN32 When a shell script is spawned from a GUI application a console window is displayed. If the noconsole option is set the console window is hidden. --- shell/ash.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/shell/ash.c b/shell/ash.c index 80a85b9eb..8f59dccda 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -281,6 +281,9 @@ static const char *const optletters_optnames[] = { ,"\0" "nolog" ,"\0" "debug" #endif +#if ENABLE_PLATFORM_MINGW32 + ,"\0" "noconsole" +#endif }; #define optletters(n) optletters_optnames[n][0] @@ -360,6 +363,9 @@ struct globals_misc { #if DEBUG # define nolog optlist[14 + ENABLE_ASH_BASH_COMPAT] # define debug optlist[15 + ENABLE_ASH_BASH_COMPAT] +#endif +#if ENABLE_PLATFORM_MINGW32 +# define noconsole optlist[14 + ENABLE_ASH_BASH_COMPAT + 2*DEBUG] #endif /* trap handler commands */ @@ -13818,6 +13824,15 @@ int ash_main(int argc UNUSED_PARAM, char **argv) } #endif procargs(argv); +#if ENABLE_PLATFORM_MINGW32 + if ( noconsole ) { + DWORD dummy; + + if ( GetConsoleProcessList(&dummy, 1) == 1 ) { + ShowWindow(GetConsoleWindow(), SW_HIDE); + } + } +#endif if (argv[0] && argv[0][0] == '-') isloginsh = 1; -- cgit v1.2.3-55-g6feb