diff options
-rw-r--r-- | libbb/lineedit.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 367396b91..b0adcf140 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -769,8 +769,6 @@ static unsigned path_parse(char ***p) | |||
769 | if (!tmp) | 769 | if (!tmp) |
770 | break; | 770 | break; |
771 | tmp++; | 771 | tmp++; |
772 | if (*tmp == '\0') | ||
773 | break; /* :<empty> */ | ||
774 | npth++; | 772 | npth++; |
775 | } | 773 | } |
776 | 774 | ||
@@ -782,8 +780,6 @@ static unsigned path_parse(char ***p) | |||
782 | if (!tmp) | 780 | if (!tmp) |
783 | break; | 781 | break; |
784 | *tmp++ = '\0'; /* ':' -> '\0' */ | 782 | *tmp++ = '\0'; /* ':' -> '\0' */ |
785 | if (*tmp == '\0') | ||
786 | break; /* :<empty> */ | ||
787 | res[npth++] = tmp; | 783 | res[npth++] = tmp; |
788 | } | 784 | } |
789 | /* special case: "match subdirectories of the current directory" */ | 785 | /* special case: "match subdirectories of the current directory" */ |
@@ -854,6 +850,7 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type) | |||
854 | struct dirent *next; | 850 | struct dirent *next; |
855 | struct stat st; | 851 | struct stat st; |
856 | char *found; | 852 | char *found; |
853 | const char *lpath; | ||
857 | 854 | ||
858 | if (paths[i] == NULL) { /* path_parse()'s last component? */ | 855 | if (paths[i] == NULL) { /* path_parse()'s last component? */ |
859 | /* in PATH completion, current dir's subdir names | 856 | /* in PATH completion, current dir's subdir names |
@@ -863,7 +860,8 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type) | |||
863 | paths[i] = (char *)"."; | 860 | paths[i] = (char *)"."; |
864 | } | 861 | } |
865 | 862 | ||
866 | dir = opendir(paths[i]); | 863 | lpath = *paths[i] ? paths[i] : "."; |
864 | dir = opendir(lpath); | ||
867 | if (!dir) | 865 | if (!dir) |
868 | continue; /* don't print an error */ | 866 | continue; /* don't print an error */ |
869 | 867 | ||
@@ -878,7 +876,7 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type) | |||
878 | if (strncmp(basecmd, name_found, baselen) != 0) | 876 | if (strncmp(basecmd, name_found, baselen) != 0) |
879 | continue; /* no */ | 877 | continue; /* no */ |
880 | 878 | ||
881 | found = concat_path_file(paths[i], name_found); | 879 | found = concat_path_file(lpath, name_found); |
882 | /* NB: stat() first so that we see is it a directory; | 880 | /* NB: stat() first so that we see is it a directory; |
883 | * but if that fails, use lstat() so that | 881 | * but if that fails, use lstat() so that |
884 | * we still match dangling links */ | 882 | * we still match dangling links */ |