From 9e2482e93913a7de1f667720a7ac619fe6fdd723 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 26 Mar 2024 16:47:14 +0000 Subject: ash: strip path from NOFORK applet names Commit 26ba73098 (win32: search PATH for missing Unix-style executables) extended the cases in which PATH would be searched for executables specified with a Unix-style path. A side effect of this change was to pass the Unix-style path as argv[0] to NOFORK applets. The 'uname' applet examines argv[0] to determine how to behave. When invoked as '/bin/uname' it returned unexpected results. Other applets may be similarly affected. When a NOFORK applet is invoked in evalcommand(), strip any path. Costs 16 bytes. (GitHub issue #392) --- shell/ash.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shell/ash.c b/shell/ash.c index 31d3c1013..d312cb8cd 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -11688,6 +11688,9 @@ evalcommand(union node *cmd, int flags) * and/or wait for user input ineligible for NOFORK: * for example, "yes" or "rm" (rm -i waits for input). */ +#if ENABLE_PLATFORM_MINGW32 + argv[0] = (char *)bb_basename(argv[0]); +#endif exitstatus = run_nofork_applet(applet_no, argv); environ = sv_environ; /* -- cgit v1.2.3-55-g6feb