From 4e21b98252d61c524048f6b1d561aba522ed5baa Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 25 Oct 2023 09:11:34 +0100 Subject: 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. --- libbb/lineedit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) # else home = getenv("HOME"); # endif - if (home != NULL && home[0] != '\0') + if (home != NULL && home[0] != '\0') { +# if ENABLE_PLATFORM_MINGW32 + char *t = auto_string(xstrdup(home)); + bs_to_slash(t); + home = t; +# endif return home; + } if (!got_user_strings) get_user_strings(); -- cgit v1.2.3-55-g6feb