diff options
author | Ron Yorston <rmy@pobox.com> | 2024-11-19 09:18:56 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-11-19 09:18:56 +0000 |
commit | 90c87dc65452889cd79debdc58d46fee76d17726 (patch) | |
tree | ae877f6fd1a6b1843c3a34d279ca1f9a9961fece /win32 | |
parent | 0e958a72e1780138e68c799792190085cf505ee7 (diff) | |
download | busybox-w32-90c87dc65452889cd79debdc58d46fee76d17726.tar.gz busybox-w32-90c87dc65452889cd79debdc58d46fee76d17726.tar.bz2 busybox-w32-90c87dc65452889cd79debdc58d46fee76d17726.zip |
ash: match behaviour of cmd.exe in cd builtin
The Windows API strips trailing dots and spaces from the last
component of a path. cmd.exe handles this quirk when changing
directory by adjusting its idea of the current directory to match
reality. The shell in busybox-w32 didn't do this, leading to some
confusion.
Fix the shell's cd builtin so it works more like cmd.exe.
Adds 64-80 bytes.
(GitHub issue #478)
Diffstat (limited to 'win32')
-rw-r--r-- | win32/mingw.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 87e7ca602..6842dba48 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -2178,6 +2178,19 @@ void FAST_FUNC slash_to_bs(char *p) | |||
2178 | } | 2178 | } |
2179 | } | 2179 | } |
2180 | 2180 | ||
2181 | /* Windows strips trailing dots and spaces from the last component of | ||
2182 | * a file path. This routine emulates that behaviour so we can preempt | ||
2183 | * Windows if necessary. */ | ||
2184 | void FAST_FUNC strip_dot_space(char *p) | ||
2185 | { | ||
2186 | char *start = (char *)bb_basename(p); | ||
2187 | char *end = start + strlen(start); | ||
2188 | |||
2189 | while (end > start && (end[-1] == '.' || end[-1] == ' ')) { | ||
2190 | *--end = '\0'; | ||
2191 | } | ||
2192 | } | ||
2193 | |||
2181 | size_t FAST_FUNC remove_cr(char *p, size_t len) | 2194 | size_t FAST_FUNC remove_cr(char *p, size_t len) |
2182 | { | 2195 | { |
2183 | ssize_t i, j; | 2196 | ssize_t i, j; |