aboutsummaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r--libbb/lineedit.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 249b401b4..a83e07c0c 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -681,7 +681,7 @@ static NOINLINE unsigned complete_username(const char *ud)
681 setpwent(); 681 setpwent();
682 while ((pw = getpwent()) != NULL) { 682 while ((pw = getpwent()) != NULL) {
683 /* Null usernames should result in all users as possible completions. */ 683 /* Null usernames should result in all users as possible completions. */
684 if (/*!userlen || */ strncmp(ud, pw->pw_name, userlen) == 0) { 684 if (/* !ud[0] || */ is_prefixed_with(pw->pw_name, ud)) {
685 add_match(xasprintf("~%s/", pw->pw_name)); 685 add_match(xasprintf("~%s/", pw->pw_name));
686 } 686 }
687 } 687 }
@@ -792,7 +792,7 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type)
792 if (!pfind[0] && DOT_OR_DOTDOT(name_found)) 792 if (!pfind[0] && DOT_OR_DOTDOT(name_found))
793 continue; 793 continue;
794 /* match? */ 794 /* match? */
795 if (strncmp(name_found, pfind, pf_len) != 0) 795 if (!is_prefixed_with(name_found, pfind))
796 continue; /* no */ 796 continue; /* no */
797 797
798 found = concat_path_file(paths[i], name_found); 798 found = concat_path_file(paths[i], name_found);
@@ -1879,15 +1879,16 @@ static void parse_and_put_prompt(const char *prmt_ptr)
1879 cwd_buf = xrealloc_getcwd_or_warn(NULL); 1879 cwd_buf = xrealloc_getcwd_or_warn(NULL);
1880 if (!cwd_buf) 1880 if (!cwd_buf)
1881 cwd_buf = (char *)bb_msg_unknown; 1881 cwd_buf = (char *)bb_msg_unknown;
1882 else { 1882 else if (home_pwd_buf[0]) {
1883 char *after_home_user;
1884
1883 /* /home/user[/something] -> ~[/something] */ 1885 /* /home/user[/something] -> ~[/something] */
1884 l = strlen(home_pwd_buf); 1886 after_home_user = is_prefixed_with(cwd_buf, home_pwd_buf);
1885 if (l != 0 1887 if (after_home_user
1886 && strncmp(home_pwd_buf, cwd_buf, l) == 0 1888 && (*after_home_user == '/' || *after_home_user == '\0')
1887 && (cwd_buf[l] == '/' || cwd_buf[l] == '\0')
1888 ) { 1889 ) {
1889 cwd_buf[0] = '~'; 1890 cwd_buf[0] = '~';
1890 overlapping_strcpy(cwd_buf + 1, cwd_buf + l); 1891 overlapping_strcpy(cwd_buf + 1, after_home_user);
1891 } 1892 }
1892 } 1893 }
1893 } 1894 }