From 9752b1d082e6bdb51f8fbec5e751087a687c0062 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 9 Apr 2019 08:30:47 +0100 Subject: lineedit: reinstate tab-completion of '~/' Commit 195902a64 (lineedit: improvements to tab completion) disabled tab-completion of usernames. It was too heavy-handed, in that it also removed tab-completion of '~/'. --- configs/mingw32_defconfig | 4 ++-- configs/mingw64_defconfig | 4 ++-- libbb/lineedit.c | 8 +++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index 7800e9340..34213e05f 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Busybox version: 1.31.0.git -# Sun Apr 7 12:34:37 2019 +# Mon Apr 8 21:26:25 2019 # CONFIG_HAVE_DOT_CONFIG=y # CONFIG_PLATFORM_POSIX is not set @@ -117,7 +117,7 @@ CONFIG_FEATURE_EDITING_SAVEHISTORY=y # CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is not set CONFIG_FEATURE_REVERSE_SEARCH=y CONFIG_FEATURE_TAB_COMPLETION=y -# CONFIG_FEATURE_USERNAME_COMPLETION is not set +CONFIG_FEATURE_USERNAME_COMPLETION=y CONFIG_FEATURE_EDITING_FANCY_PROMPT=y # CONFIG_FEATURE_EDITING_WINCH is not set # CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index f39e02fca..b8a3a03d5 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Busybox version: 1.31.0.git -# Sun Apr 7 12:34:37 2019 +# Mon Apr 8 21:26:25 2019 # CONFIG_HAVE_DOT_CONFIG=y # CONFIG_PLATFORM_POSIX is not set @@ -117,7 +117,7 @@ CONFIG_FEATURE_EDITING_SAVEHISTORY=y # CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is not set CONFIG_FEATURE_REVERSE_SEARCH=y CONFIG_FEATURE_TAB_COMPLETION=y -# CONFIG_FEATURE_USERNAME_COMPLETION is not set +CONFIG_FEATURE_USERNAME_COMPLETION=y CONFIG_FEATURE_EDITING_FANCY_PROMPT=y # CONFIG_FEATURE_EDITING_WINCH is not set # CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 0d5ce9082..191bc0598 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -729,13 +729,16 @@ static void add_match(char *matched) */ static char *username_path_completion(char *ud) { +# if !ENABLE_PLATFORM_MINGW32 struct passwd *entry; +#endif char *tilde_name = ud; char *home = NULL; ud++; /* skip ~ */ if (*ud == '/') { /* "~/..." */ home = home_pwd_buf; +# if !ENABLE_PLATFORM_MINGW32 } else { /* "~user/..." */ ud = strchr(ud, '/'); @@ -744,6 +747,7 @@ static char *username_path_completion(char *ud) *ud = '/'; /* restore "~user/..." */ if (entry) home = entry->pw_dir; +# endif } if (home) { ud = concat_path_file(home, ud); @@ -753,6 +757,7 @@ static char *username_path_completion(char *ud) return tilde_name; } +# if !ENABLE_PLATFORM_MINGW32 /* ~use - find all users with this prefix. * Return the length of the prefix used for matching. */ @@ -775,6 +780,7 @@ static NOINLINE unsigned complete_username(const char *ud) return 1 + userlen; } +# endif # endif /* FEATURE_USERNAME_COMPLETION */ enum { @@ -1237,7 +1243,7 @@ static NOINLINE void input_tab(smallint *lastWasTab) /* Free up any memory already allocated */ free_tab_completion_data(); -# if ENABLE_FEATURE_USERNAME_COMPLETION +# if ENABLE_FEATURE_USERNAME_COMPLETION && !ENABLE_PLATFORM_MINGW32 /* If the word starts with ~ and there is no slash in the word, * then try completing this word as a username. */ if (state->flags & USERNAME_COMPLETION) -- cgit v1.2.3-55-g6feb