diff options
-rw-r--r-- | shell/ash.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/shell/ash.c b/shell/ash.c index 9ed8506ab..da139f89b 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -192,9 +192,10 @@ | |||
192 | //config: depends on (ASH || SH_IS_ASH || BASH_IS_ASH) && PLATFORM_MINGW32 | 192 | //config: depends on (ASH || SH_IS_ASH || BASH_IS_ASH) && PLATFORM_MINGW32 |
193 | //config: help | 193 | //config: help |
194 | //config: Enable support for the 'noconsole' option, which attempts to | 194 | //config: Enable support for the 'noconsole' option, which attempts to |
195 | //config: hide the console normally associated with a command line | 195 | //config: conceal the console normally associated with a command line |
196 | //config: application. This may be useful when running a shell script | 196 | //config: application. This may be useful when running a shell script |
197 | //config: from a GUI application. | 197 | //config: from a GUI application. Also the 'noiconify' option, which |
198 | //config: controls whether the console is iconfified or hidden. | ||
198 | //config: | 199 | //config: |
199 | //config:config ASH_GLOB_OPTIONS | 200 | //config:config ASH_GLOB_OPTIONS |
200 | //config: bool "Globbing options" | 201 | //config: bool "Globbing options" |
@@ -505,6 +506,7 @@ static const char *const optletters_optnames[] ALIGN_PTR = { | |||
505 | #endif | 506 | #endif |
506 | #if ENABLE_ASH_NOCONSOLE | 507 | #if ENABLE_ASH_NOCONSOLE |
507 | ,"\0" "noconsole" | 508 | ,"\0" "noconsole" |
509 | ,"\0" "noiconify" | ||
508 | #endif | 510 | #endif |
509 | #if ENABLE_ASH_GLOB_OPTIONS | 511 | #if ENABLE_ASH_GLOB_OPTIONS |
510 | ,"\0" "nocaseglob" | 512 | ,"\0" "nocaseglob" |
@@ -635,11 +637,12 @@ struct globals_misc { | |||
635 | # define winxp optlist[16 + BASH_PIPEFAIL + 2*(DEBUG != 0)] | 637 | # define winxp optlist[16 + BASH_PIPEFAIL + 2*(DEBUG != 0)] |
636 | # if ENABLE_ASH_NOCONSOLE | 638 | # if ENABLE_ASH_NOCONSOLE |
637 | # define noconsole optlist[17 + BASH_PIPEFAIL + 2*(DEBUG != 0)] | 639 | # define noconsole optlist[17 + BASH_PIPEFAIL + 2*(DEBUG != 0)] |
640 | # define noiconify optlist[18 + BASH_PIPEFAIL + 2*(DEBUG != 0)] | ||
638 | # endif | 641 | # endif |
639 | # if ENABLE_ASH_GLOB_OPTIONS | 642 | # if ENABLE_ASH_GLOB_OPTIONS |
640 | # define nocaseglob optlist[17 + BASH_PIPEFAIL + 2*(DEBUG != 0) + ENABLE_ASH_NOCONSOLE] | 643 | # define nocaseglob optlist[17 + BASH_PIPEFAIL + 2*(DEBUG != 0) + 2*ENABLE_ASH_NOCONSOLE] |
641 | # define nohiddenglob optlist[18 + BASH_PIPEFAIL + 2*(DEBUG != 0) + ENABLE_ASH_NOCONSOLE] | 644 | # define nohiddenglob optlist[18 + BASH_PIPEFAIL + 2*(DEBUG != 0) + 2*ENABLE_ASH_NOCONSOLE] |
642 | # define nohidsysglob optlist[19 + BASH_PIPEFAIL + 2*(DEBUG != 0) + ENABLE_ASH_NOCONSOLE] | 645 | # define nohidsysglob optlist[19 + BASH_PIPEFAIL + 2*(DEBUG != 0) + 2*ENABLE_ASH_NOCONSOLE] |
643 | # endif | 646 | # endif |
644 | #endif | 647 | #endif |
645 | 648 | ||
@@ -2969,17 +2972,25 @@ setwinxp(int on) | |||
2969 | /* | 2972 | /* |
2970 | * Console state is either: | 2973 | * Console state is either: |
2971 | * 0 normal | 2974 | * 0 normal |
2972 | * 1 iconified | 2975 | * 1 iconified/hidden |
2973 | * 2 unknown | 2976 | * 2 unknown |
2974 | */ | 2977 | */ |
2975 | static int console_state(void) | 2978 | static int console_state(void) |
2976 | { | 2979 | { |
2977 | DECLARE_PROC_ADDR(BOOL, ShowWindow, HWND, int); | 2980 | DECLARE_PROC_ADDR(BOOL, ShowWindow, HWND, int); |
2978 | DECLARE_PROC_ADDR(BOOL, IsIconic, HWND); | ||
2979 | 2981 | ||
2980 | if (INIT_PROC_ADDR(user32.dll, ShowWindow) && | 2982 | if (INIT_PROC_ADDR(user32.dll, ShowWindow)) { |
2981 | INIT_PROC_ADDR(user32.dll, IsIconic)) { | 2983 | BOOL state; |
2982 | return IsIconic(GetConsoleWindow()) != 0; | 2984 | |
2985 | if (noiconify) { | ||
2986 | state = IsWindowVisible(GetConsoleWindow()); | ||
2987 | if (state >= 0) | ||
2988 | return state == 0; | ||
2989 | } else { | ||
2990 | state = IsIconic(GetConsoleWindow()); | ||
2991 | if (state >= 0) | ||
2992 | return state != 0; | ||
2993 | } | ||
2983 | } | 2994 | } |
2984 | return 2; | 2995 | return 2; |
2985 | } | 2996 | } |
@@ -2988,7 +2999,8 @@ static void hide_console(int hide) | |||
2988 | { | 2999 | { |
2989 | // Switch console state if it's known and isn't the required state | 3000 | // Switch console state if it's known and isn't the required state |
2990 | if (console_state() == !hide) | 3001 | if (console_state() == !hide) |
2991 | ShowWindow(GetConsoleWindow(), hide ? SW_MINIMIZE : SW_NORMAL); | 3002 | ShowWindow(GetConsoleWindow(), hide ? |
3003 | (noiconify ? SW_HIDE : SW_MINIMIZE) : SW_NORMAL); | ||
2992 | } | 3004 | } |
2993 | # endif | 3005 | # endif |
2994 | #endif | 3006 | #endif |