diff options
author | Ron Yorston <rmy@pobox.com> | 2019-03-30 11:30:20 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2019-03-30 11:56:56 +0000 |
commit | be2949717934c19890879cf2a8fc74c5da55d1c7 (patch) | |
tree | 3207e0b18137525309787e0fa9e7a732f04983b7 /libbb | |
parent | 077d4c21c0e48e495bc86ea0dec28e5a7143efa8 (diff) | |
download | busybox-w32-be2949717934c19890879cf2a8fc74c5da55d1c7.tar.gz busybox-w32-be2949717934c19890879cf2a8fc74c5da55d1c7.tar.bz2 busybox-w32-be2949717934c19890879cf2a8fc74c5da55d1c7.zip |
win32: improved support for c:path path names
Microsoft Windows permits path names of the form 'c:path', without a
path separator after the colon. The system records a current directory
for each drive and the path is interpreted relative to that.
Since Windows API calls understand 'c:path' path names many commands
in busybox-w32 already work with them. This commit adds the following:
- The 'cd' shell built-in interprets 'c:path' path names correctly.
Previously it treated them as relative to the shell's concept of
the current working directory, not the current directory of the
specified drive.
- The 'pwd' shell built-in takes the '-a' option to list the current
directory for all drives.
- 'c:path' path names are subject to tab-completion.
Paths of the form 'c:path' don't work for mapped network drives or
paths that have been associated with a drive using SUBST.
See GitHub issue #147.
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/lineedit.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 3725dba0d..0d5ce9082 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -843,6 +843,17 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type) | |||
843 | path1[0] = (char*)"."; | 843 | path1[0] = (char*)"."; |
844 | 844 | ||
845 | pfind = strrchr(command, '/'); | 845 | pfind = strrchr(command, '/'); |
846 | #if ENABLE_PLATFORM_MINGW32 | ||
847 | if (!pfind && has_dos_drive_prefix(command) && command[2] != '\0') { | ||
848 | char buffer[PATH_MAX]; | ||
849 | |||
850 | /* path is of form c:path with no '/' */ | ||
851 | if (get_drive_cwd(command, buffer, PATH_MAX)) { | ||
852 | pfind = command + 2; | ||
853 | path1[0] = xstrdup(buffer); | ||
854 | } | ||
855 | } else | ||
856 | #endif | ||
846 | if (!pfind) { | 857 | if (!pfind) { |
847 | if (type == FIND_EXE_ONLY) | 858 | if (type == FIND_EXE_ONLY) |
848 | npaths = path_parse(&paths); | 859 | npaths = path_parse(&paths); |