aboutsummaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-04-09 08:30:47 +0100
committerRon Yorston <rmy@pobox.com>2019-04-09 08:34:15 +0100
commit9752b1d082e6bdb51f8fbec5e751087a687c0062 (patch)
tree146518783edc4b16a3a39452dd0109a7d8c1ee02 /libbb/lineedit.c
parentde3b8f89b1ea54ae51314e20c8d8d1c9b9fd14ad (diff)
downloadbusybox-w32-9752b1d082e6bdb51f8fbec5e751087a687c0062.tar.gz
busybox-w32-9752b1d082e6bdb51f8fbec5e751087a687c0062.tar.bz2
busybox-w32-9752b1d082e6bdb51f8fbec5e751087a687c0062.zip
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 '~/'.
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r--libbb/lineedit.c8
1 files changed, 7 insertions, 1 deletions
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)
729 */ 729 */
730static char *username_path_completion(char *ud) 730static char *username_path_completion(char *ud)
731{ 731{
732# if !ENABLE_PLATFORM_MINGW32
732 struct passwd *entry; 733 struct passwd *entry;
734#endif
733 char *tilde_name = ud; 735 char *tilde_name = ud;
734 char *home = NULL; 736 char *home = NULL;
735 737
736 ud++; /* skip ~ */ 738 ud++; /* skip ~ */
737 if (*ud == '/') { /* "~/..." */ 739 if (*ud == '/') { /* "~/..." */
738 home = home_pwd_buf; 740 home = home_pwd_buf;
741# if !ENABLE_PLATFORM_MINGW32
739 } else { 742 } else {
740 /* "~user/..." */ 743 /* "~user/..." */
741 ud = strchr(ud, '/'); 744 ud = strchr(ud, '/');
@@ -744,6 +747,7 @@ static char *username_path_completion(char *ud)
744 *ud = '/'; /* restore "~user/..." */ 747 *ud = '/'; /* restore "~user/..." */
745 if (entry) 748 if (entry)
746 home = entry->pw_dir; 749 home = entry->pw_dir;
750# endif
747 } 751 }
748 if (home) { 752 if (home) {
749 ud = concat_path_file(home, ud); 753 ud = concat_path_file(home, ud);
@@ -753,6 +757,7 @@ static char *username_path_completion(char *ud)
753 return tilde_name; 757 return tilde_name;
754} 758}
755 759
760# if !ENABLE_PLATFORM_MINGW32
756/* ~use<tab> - find all users with this prefix. 761/* ~use<tab> - find all users with this prefix.
757 * Return the length of the prefix used for matching. 762 * Return the length of the prefix used for matching.
758 */ 763 */
@@ -775,6 +780,7 @@ static NOINLINE unsigned complete_username(const char *ud)
775 780
776 return 1 + userlen; 781 return 1 + userlen;
777} 782}
783# endif
778# endif /* FEATURE_USERNAME_COMPLETION */ 784# endif /* FEATURE_USERNAME_COMPLETION */
779 785
780enum { 786enum {
@@ -1237,7 +1243,7 @@ static NOINLINE void input_tab(smallint *lastWasTab)
1237 /* Free up any memory already allocated */ 1243 /* Free up any memory already allocated */
1238 free_tab_completion_data(); 1244 free_tab_completion_data();
1239 1245
1240# if ENABLE_FEATURE_USERNAME_COMPLETION 1246# if ENABLE_FEATURE_USERNAME_COMPLETION && !ENABLE_PLATFORM_MINGW32
1241 /* If the word starts with ~ and there is no slash in the word, 1247 /* If the word starts with ~ and there is no slash in the word,
1242 * then try completing this word as a username. */ 1248 * then try completing this word as a username. */
1243 if (state->flags & USERNAME_COMPLETION) 1249 if (state->flags & USERNAME_COMPLETION)