On Sun, Nov 21, 2021 at 03:36:33PM +0000, Luís Henriques wrote:
> Hi!
>
> I always found it annoying that, in ksh, doing:
>
> $ ls ..
>
> followed by TAB doesn't allow me to list the options (i.e. show files/dirs
> in '..'). I need to do add a trailing '/' to this 'ls' command in order
> to have the completions listed.
ping. I'm just wondering if this is something worth pursuing or if people
aren't simply interested and I should drop it.
Cheers,
--
Luís
>
> This diff makes this work without the trailing '/', but I'll be honest:
> I'm not familiar with this code which does all sort of complex parsing
> stuff. So... yeah, I may be breaking something somewhere.
>
> Cheers,
> --
> Luís
>
> diff 6911632ba3a60c1920af7c2d3d79a0a56f9f2d4c /usr/src
> blob - 3089d195d2084b3fa81196fa359818ec914c54b0
> file + bin/ksh/edit.c
> --- bin/ksh/edit.c
> +++ bin/ksh/edit.c
> @@ -701,7 +701,10 @@ add_glob(const char *str, int slen)
> if (slen < 0)
> return NULL;
>
> - toglob = str_nsave(str, slen + 1, ATEMP); /* + 1 for "*" */
> + /*
> + * + 2 for '*' and for '/' if str is '..'
> + */
> + toglob = str_nsave(str, slen + 2, ATEMP); /* + 1 for "*" */
> toglob[slen] = '\0';
>
> /*
> @@ -720,8 +723,15 @@ add_glob(const char *str, int slen)
> saw_slash = true;
> }
> if (!*s && (*toglob != '~' || saw_slash)) {
> - toglob[slen] = '*';
> - toglob[slen + 1] = '\0';
> + /* If we're dealing with '..' */
> + if (slen == 2 && toglob[0] == '.' && toglob[1] == '.') {
> + toglob[slen] = '/';
> + toglob[slen + 1] = '*';
> + toglob[slen + 2] = '\0';
> + } else {
> + toglob[slen] = '*';
> + toglob[slen + 1] = '\0';
> + }
> }
>
> return toglob;
>