diff options
author | Ron Yorston <rmy@pobox.com> | 2023-10-25 09:11:34 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-10-25 09:11:34 +0100 |
commit | 4e21b98252d61c524048f6b1d561aba522ed5baa (patch) | |
tree | cf428989f83f70feee3cae92a7f08ff37817e984 | |
parent | e0fd5d3c112df92b3d104b519ed09770f24d2ecf (diff) | |
download | busybox-w32-4e21b98252d61c524048f6b1d561aba522ed5baa.tar.gz busybox-w32-4e21b98252d61c524048f6b1d561aba522ed5baa.tar.bz2 busybox-w32-4e21b98252d61c524048f6b1d561aba522ed5baa.zip |
lineedit: normalise HOME for use in prompt
The code to replace the user's home directory with '~' in the
prompt didn't allow for the possibility of the HOME environment
variable having backslashes in the path.
Convert backslashes to forward slashes in HOME. This isn't necessary
if the home directory is obtained from getpwuid(3) as it's already
converted there.
Adds 24-32 bytes.
-rw-r--r-- | libbb/lineedit.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index e7729996f..1a118eb92 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -258,8 +258,14 @@ static NOINLINE const char *get_homedir_or_NULL(void) | |||
258 | # else | 258 | # else |
259 | home = getenv("HOME"); | 259 | home = getenv("HOME"); |
260 | # endif | 260 | # endif |
261 | if (home != NULL && home[0] != '\0') | 261 | if (home != NULL && home[0] != '\0') { |
262 | # if ENABLE_PLATFORM_MINGW32 | ||
263 | char *t = auto_string(xstrdup(home)); | ||
264 | bs_to_slash(t); | ||
265 | home = t; | ||
266 | # endif | ||
262 | return home; | 267 | return home; |
268 | } | ||
263 | 269 | ||
264 | if (!got_user_strings) | 270 | if (!got_user_strings) |
265 | get_user_strings(); | 271 | get_user_strings(); |