[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] lineedit: match local directories when searching PATH
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2020-12-16 10:39:58
Message-ID: CAK1hOcMUtiAn8+Z-88Td9g2psTJmjZ4w3iYEXTZj_iLiEdeD6g () mail ! gmail ! com
[Download RAW message or body]

Applied both patches, thank you.

On Fri, Dec 11, 2020 at 1:34 PM Ron Yorston <rmy@pobox.com> wrote:
>
> When tab-completing a command we search PATH if the partial text
> doesn't include a slash.  Also match subdirectories of the current
> directory, in case the user intends to run a binary from one of
> them.
>
> function                                             old     new   delta
> complete_cmd_dir_file                                894     917     +23
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 1/0 up/down: 23/0)               Total: 23 bytes
>
> Signed-off-by: Ron Yorston <rmy@pobox.com>
> ---
>  libbb/lineedit.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/libbb/lineedit.c b/libbb/lineedit.c
> index d64d7d0c2..5eb701f00 100644
> --- a/libbb/lineedit.c
> +++ b/libbb/lineedit.c
> @@ -753,7 +753,7 @@ static int path_parse(char ***p)
>                 return 1;
>
>         tmp = (char*)pth;
> -       npth = 1; /* path component count */
> +       npth = 2; /* path component count */
>         while (1) {
>                 tmp = strchr(tmp, ':');
>                 if (!tmp)
> @@ -776,6 +776,8 @@ static int path_parse(char ***p)
>                         break; /* :<empty> */
>                 res[npth++] = tmp;
>         }
> +       /* special case: match subdirectories of the current directory */
> +       res[npth++] = NULL;
>         return npth;
>  }
>
> @@ -843,6 +845,11 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type)
>                 struct stat st;
>                 char *found;
>
> +               if (paths[i] == NULL) {
> +                       type = FIND_DIR_ONLY;
> +                       paths[i] = (char *)".";
> +               }
> +
>                 dir = opendir(paths[i]);
>                 if (!dir)
>                         continue; /* don't print an error */
> --
> 2.29.2
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic