diff options
| author | Ron Yorston <rmy@pobox.com> | 2023-06-01 13:52:33 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2023-06-01 14:03:51 +0100 |
| commit | a1ccb78df0a218d8fa760015f82bca6b7939b95b (patch) | |
| tree | 2ab8ed04eadafc0ea6f709f2bf3fa5f267135491 | |
| parent | 82accfc19fcbda7cd2245a727ca493b582fb0994 (diff) | |
| download | busybox-w32-a1ccb78df0a218d8fa760015f82bca6b7939b95b.tar.gz busybox-w32-a1ccb78df0a218d8fa760015f82bca6b7939b95b.tar.bz2 busybox-w32-a1ccb78df0a218d8fa760015f82bca6b7939b95b.zip | |
ash: enable 'set -/+o noconsole'
Previously the 'noconsole' shell option could only be set as a
shell command line option. Allow it to be changed from within
the shell by 'set -o noconsole' or 'set +o noconsole'.
The console window is now minimised rather than hidden. This
makes it easier for the user to access the console when 'noconsole'
is in effect.
Adds 8-32 bytes.
(GitHub issue #325)
| -rw-r--r-- | include/mingw.h | 2 | ||||
| -rw-r--r-- | shell/ash.c | 8 | ||||
| -rw-r--r-- | win32/mingw.c | 14 |
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 | ||
| 578 | ssize_t get_random_bytes(void *buf, ssize_t count); | 578 | ssize_t get_random_bytes(void *buf, ssize_t count); |
| 579 | int enumerate_links(const char *file, char *name); | 579 | int enumerate_links(const char *file, char *name); |
| 580 | void hide_console(void); | 580 | void hide_console(int); |
| 581 | 581 | ||
| 582 | int unc_root_len(const char *dir); | 582 | int unc_root_len(const char *dir); |
| 583 | int root_len(const char *path); | 583 | int 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 | ||
| 10794 | struct localvar_list { | 10797 | struct 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 |
| 2188 | void hide_console(void) | 2188 | void 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 |
