diff options
-rw-r--r-- | include/mingw.h | 1 | ||||
-rw-r--r-- | shell/ash.c | 31 | ||||
-rw-r--r-- | win32/mingw.c | 14 |
3 files changed, 31 insertions, 15 deletions
diff --git a/include/mingw.h b/include/mingw.h index 97db2f6a9..6e851b43d 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -609,7 +609,6 @@ ULONGLONG CompatGetTickCount64(void); | |||
609 | 609 | ||
610 | ssize_t get_random_bytes(void *buf, ssize_t count); | 610 | ssize_t get_random_bytes(void *buf, ssize_t count); |
611 | int enumerate_links(const char *file, char *name); | 611 | int enumerate_links(const char *file, char *name); |
612 | void hide_console(int); | ||
613 | 612 | ||
614 | int unc_root_len(const char *dir); | 613 | int unc_root_len(const char *dir); |
615 | int root_len(const char *path); | 614 | int root_len(const char *path); |
diff --git a/shell/ash.c b/shell/ash.c index 41bf45734..2ea87a049 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -252,6 +252,7 @@ | |||
252 | #endif | 252 | #endif |
253 | #if ENABLE_PLATFORM_MINGW32 | 253 | #if ENABLE_PLATFORM_MINGW32 |
254 | # include <conio.h> | 254 | # include <conio.h> |
255 | # include "lazyload.h" | ||
255 | #endif | 256 | #endif |
256 | 257 | ||
257 | /* So far, all bash compat is controlled by one config option */ | 258 | /* So far, all bash compat is controlled by one config option */ |
@@ -2994,6 +2995,33 @@ setwinxp(int on) | |||
2994 | } | 2995 | } |
2995 | } | 2996 | } |
2996 | } | 2997 | } |
2998 | |||
2999 | # if ENABLE_ASH_NOCONSOLE | ||
3000 | /* | ||
3001 | * Console state is either: | ||
3002 | * 0 normal | ||
3003 | * 1 iconified | ||
3004 | * 2 unknown | ||
3005 | */ | ||
3006 | static int console_state(void) | ||
3007 | { | ||
3008 | DECLARE_PROC_ADDR(BOOL, ShowWindow, HWND, int); | ||
3009 | DECLARE_PROC_ADDR(BOOL, IsIconic, HWND); | ||
3010 | |||
3011 | if (INIT_PROC_ADDR(user32.dll, ShowWindow) && | ||
3012 | INIT_PROC_ADDR(user32.dll, IsIconic)) { | ||
3013 | return IsIconic(GetConsoleWindow()) != 0; | ||
3014 | } | ||
3015 | return 2; | ||
3016 | } | ||
3017 | |||
3018 | static void hide_console(int hide) | ||
3019 | { | ||
3020 | // Switch console state if it's known and isn't the required state | ||
3021 | if (console_state() == !hide) | ||
3022 | ShowWindow(GetConsoleWindow(), hide ? SW_MINIMIZE : SW_NORMAL); | ||
3023 | } | ||
3024 | # endif | ||
2997 | #endif | 3025 | #endif |
2998 | 3026 | ||
2999 | 3027 | ||
@@ -12616,6 +12644,9 @@ options(int *login_sh) | |||
12616 | #if ENABLE_PLATFORM_MINGW32 | 12644 | #if ENABLE_PLATFORM_MINGW32 |
12617 | dirarg = NULL; | 12645 | dirarg = NULL; |
12618 | title = NULL; | 12646 | title = NULL; |
12647 | # if ENABLE_ASH_NOCONSOLE | ||
12648 | noconsole = console_state(); | ||
12649 | # endif | ||
12619 | # if ENABLE_SUW32 | 12650 | # if ENABLE_SUW32 |
12620 | delayexit = 0; | 12651 | delayexit = 0; |
12621 | # endif | 12652 | # endif |
diff --git a/win32/mingw.c b/win32/mingw.c index dabb2a2e7..fec6df73a 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -2219,20 +2219,6 @@ int enumerate_links(const char *file, char *name) | |||
2219 | } | 2219 | } |
2220 | #endif | 2220 | #endif |
2221 | 2221 | ||
2222 | #if ENABLE_ASH_NOCONSOLE | ||
2223 | void hide_console(int hide) | ||
2224 | { | ||
2225 | DECLARE_PROC_ADDR(BOOL, ShowWindow, HWND, int); | ||
2226 | DECLARE_PROC_ADDR(BOOL, IsIconic, HWND); | ||
2227 | |||
2228 | if (INIT_PROC_ADDR(user32.dll, ShowWindow) && | ||
2229 | INIT_PROC_ADDR(user32.dll, IsIconic)) { | ||
2230 | if (IsIconic(GetConsoleWindow()) == !hide) | ||
2231 | ShowWindow(GetConsoleWindow(), hide ? SW_MINIMIZE : SW_NORMAL); | ||
2232 | } | ||
2233 | } | ||
2234 | #endif | ||
2235 | |||
2236 | /* Return the length of the root of a UNC path, i.e. the '//host/share' | 2222 | /* Return the length of the root of a UNC path, i.e. the '//host/share' |
2237 | * component, or 0 if the path doesn't look like that. */ | 2223 | * component, or 0 if the path doesn't look like that. */ |
2238 | int unc_root_len(const char *dir) | 2224 | int unc_root_len(const char *dir) |