diff options
author | Ron Yorston <rmy@pobox.com> | 2020-08-13 13:56:17 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-08-13 14:58:01 +0100 |
commit | 6059723900f2af1fbd394c457d1feae342e344f6 (patch) | |
tree | 146c10c821977a8af0942cc930d3a4550cf4a624 /libbb/executable.c | |
parent | 7d639339e0c46311f8873d560e6f168e71473cd9 (diff) | |
download | busybox-w32-6059723900f2af1fbd394c457d1feae342e344f6.tar.gz busybox-w32-6059723900f2af1fbd394c457d1feae342e344f6.tar.bz2 busybox-w32-6059723900f2af1fbd394c457d1feae342e344f6.zip |
win32: handle Unix-style absolute paths for executables
As noted in commit 548ec7045 (win32: interpret absolute paths as
relative to %SYSTEMDRIVE%) a path starting with a '/' in the Unix
world is treated as relative to the current drive by Windows.
To avoid ambiguity that commit considered certain such paths to
be relative to %SYSTEMDRIVE%. Extend this to paths representing
executables.
Add the functions need_system_drive() and auto_add_system_drive()
to detect the need for a system drive prefix and to add it if
necessary. Use these functions in:
- the 'which' applet
- the find_executable() function
- tab-completion code
- PATH look-up, shellexec(), describe_command() and find_command() in ash
- parse_interpreter() and mingw_spawn_1()
With these changes executable paths starting with a slash are
handled consistently, whatever the current drive.
Diffstat (limited to 'libbb/executable.c')
-rw-r--r-- | libbb/executable.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libbb/executable.c b/libbb/executable.c index 87a40eeda..0a0769ef3 100644 --- a/libbb/executable.c +++ b/libbb/executable.c | |||
@@ -49,6 +49,9 @@ char* FAST_FUNC find_executable(const char *filename, char **PATHp) | |||
49 | 49 | ||
50 | n = strchr(p, PATH_SEP); | 50 | n = strchr(p, PATH_SEP); |
51 | if (n) *n = '\0'; | 51 | if (n) *n = '\0'; |
52 | #if ENABLE_PLATFORM_MINGW32 | ||
53 | p = auto_add_system_drive(p); | ||
54 | #endif | ||
52 | p = concat_path_file( | 55 | p = concat_path_file( |
53 | p[0] ? p : ".", /* handle "::" case */ | 56 | p[0] ? p : ".", /* handle "::" case */ |
54 | filename | 57 | filename |