On 2016/09/08 10:45, Nicholas Marriott wrote:
> Yeah we probably shouldn't bother to look for commands that aren't 
> [A-Za-z0-9_-]:

I don't think - is necessary, it's not a valid character for an array
name so it can't be used here anyway. Otherwise OK.

> Index: edit.c
> ===================================================================
> RCS file: /cvs/src/bin/ksh/edit.c,v
> retrieving revision 1.56
> diff -u -p -r1.56 edit.c
> --- edit.c    7 Sep 2016 04:42:31 -0000       1.56
> +++ edit.c    8 Sep 2016 09:45:21 -0000
> @@ -584,9 +584,8 @@ x_try_array(const char *buf, int buflen,
>      int *nwords, char ***words)
>  {
>       const char *cmd, *cp;
> -     int cmdlen, n;
> +     int cmdlen, n, i, slen;
>       char *name, *s;
> -     size_t slen;
>       struct tbl *v, *vp;
>  
>       *nwords = 0;
> @@ -604,6 +603,10 @@ x_try_array(const char *buf, int buflen,
>       cmdlen = 0;
>       while (cmd + cmdlen < want && !isspace((u_char)cmd[cmdlen]))
>               cmdlen++;
> +     for (i = 0; i < cmdlen; i++) {
> +             if (!isalnum((u_char)cmd[i]) && cmd[i] != '_' && cmd[i] != '-')
> +                     return 0;
> +     }
>  
>       /* Take a stab at argument count from here. */
>       n = 1;
> 
> 
> On Thu, Sep 08, 2016 at 09:43:53AM +0100, Stuart Henderson wrote:
> > I just ran into this which was introduced with custom completions
> > (I haven't setup any complete_* arrays).
> > 
> > $ ag "(foo)[^_]" /u<tab>
> > 
> > results in

Reply via email to