aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mingw.h2
-rw-r--r--shell/ash.c8
-rw-r--r--win32/mingw.c14
3 files changed, 10 insertions, 14 deletions
diff --git a/include/mingw.h b/include/mingw.h
index 13adf9017..e937a9e3c 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -577,7 +577,7 @@ ULONGLONG CompatGetTickCount64(void);
577 577
578ssize_t get_random_bytes(void *buf, ssize_t count); 578ssize_t get_random_bytes(void *buf, ssize_t count);
579int enumerate_links(const char *file, char *name); 579int enumerate_links(const char *file, char *name);
580void hide_console(void); 580void hide_console(int);
581 581
582int unc_root_len(const char *dir); 582int unc_root_len(const char *dir);
583int root_len(const char *path); 583int root_len(const char *path);
diff --git a/shell/ash.c b/shell/ash.c
index 09e8725bf..fda4541b4 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -10789,6 +10789,9 @@ optschanged(void)
10789#else 10789#else
10790 viflag = 0; /* forcibly keep the option off */ 10790 viflag = 0; /* forcibly keep the option off */
10791#endif 10791#endif
10792#if ENABLE_ASH_NOCONSOLE
10793 hide_console(noconsole);
10794#endif
10792} 10795}
10793 10796
10794struct localvar_list { 10797struct localvar_list {
@@ -16075,11 +16078,6 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
16075 trace_puts_args(argv); 16078 trace_puts_args(argv);
16076#endif 16079#endif
16077 16080
16078#if ENABLE_ASH_NOCONSOLE
16079 if (noconsole)
16080 hide_console();
16081#endif
16082
16083#if ENABLE_PLATFORM_MINGW32 16081#if ENABLE_PLATFORM_MINGW32
16084 if (dirarg) { 16082 if (dirarg) {
16085 chdir(dirarg); 16083 chdir(dirarg);
diff --git a/win32/mingw.c b/win32/mingw.c
index be4fc7aa1..2cf4a45a2 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -2185,17 +2185,15 @@ int enumerate_links(const char *file, char *name)
2185#endif 2185#endif
2186 2186
2187#if ENABLE_ASH_NOCONSOLE 2187#if ENABLE_ASH_NOCONSOLE
2188void hide_console(void) 2188void hide_console(int hide)
2189{ 2189{
2190 DWORD dummy;
2191 DECLARE_PROC_ADDR(DWORD, GetConsoleProcessList, LPDWORD, DWORD);
2192 DECLARE_PROC_ADDR(BOOL, ShowWindow, HWND, int); 2190 DECLARE_PROC_ADDR(BOOL, ShowWindow, HWND, int);
2191 DECLARE_PROC_ADDR(BOOL, IsIconic, HWND);
2193 2192
2194 if (INIT_PROC_ADDR(kernel32.dll, GetConsoleProcessList) && 2193 if (INIT_PROC_ADDR(user32.dll, ShowWindow) &&
2195 INIT_PROC_ADDR(user32.dll, ShowWindow)) { 2194 INIT_PROC_ADDR(user32.dll, IsIconic)) {
2196 if (GetConsoleProcessList(&dummy, 1) == 1) { 2195 if (IsIconic(GetConsoleWindow()) == !hide)
2197 ShowWindow(GetConsoleWindow(), SW_HIDE); 2196 ShowWindow(GetConsoleWindow(), hide ? SW_MINIMIZE : SW_NORMAL);
2198 }
2199 } 2197 }
2200} 2198}
2201#endif 2199#endif