diff options
author | Ron Yorston <rmy@pobox.com> | 2021-03-02 11:54:14 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-03-02 11:54:14 +0000 |
commit | 633e3a5eae29c5074ada2655caac74902df1acc0 (patch) | |
tree | 19c71892ffadbedd316f8b01c42240a90a896566 /shell | |
parent | eecc23b563b9759556f3ccf9a8595e7bb6a2215c (diff) | |
download | busybox-w32-633e3a5eae29c5074ada2655caac74902df1acc0.tar.gz busybox-w32-633e3a5eae29c5074ada2655caac74902df1acc0.tar.bz2 busybox-w32-633e3a5eae29c5074ada2655caac74902df1acc0.zip |
ash: correctly identify applet in getopt() error messages
With the default configuration most applets are run from the shell
via run_noexec_applet_and_exit(). If the applet runs getopt() and
an error is detected the message takes the form:
sh: unknown option -- q
This happens because mingw-w64's implementation of getopt() uses
the global variable __argv[0] as the name of the program.
Avoid the misleading message by setting __argv[0] as appropriate.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c index 8cc7a5c75..3d6f25802 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -8689,6 +8689,8 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c | |||
8689 | struct forkshell *fs = (struct forkshell *)sticky_mem_start; | 8689 | struct forkshell *fs = (struct forkshell *)sticky_mem_start; |
8690 | if (applet_main[applet_no] != ash_main || | 8690 | if (applet_main[applet_no] != ash_main || |
8691 | (fs && fs->fpid == FS_SHELLEXEC)) { | 8691 | (fs && fs->fpid == FS_SHELLEXEC)) { |
8692 | /* mingw-w64's getopt() uses __argv[0] as the program name */ | ||
8693 | __argv[0] = (char *)cmd; | ||
8692 | # else | 8694 | # else |
8693 | if (APPLET_IS_NOEXEC(applet_no)) { | 8695 | if (APPLET_IS_NOEXEC(applet_no)) { |
8694 | # endif | 8696 | # endif |