[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Resolving quoted COMP_CWORD on bash-4
From: |
Chet Ramey |
Subject: |
Re: Resolving quoted COMP_CWORD on bash-4 |
Date: |
Sat, 26 Sep 2009 16:41:20 -0400 |
> Bash Version: 4.0
> Patch Level: 28
> Release Status: release
>
> On bash-4, when completing:
>
> $ a 'b c
>
> The COMP_CWORD variables contain:
>
> COMP_CWORD: 3
> COMP_CWORDS:
> 0: a
> 1: '
> 2: b
> 3: c
>
> Whereas on bash-3 they contained:
>
> COMP_CWORD: 1
> COMP_CWORDS:
> 0: a
> 1: 'b c
Try this quick-and-dirty patch and tell me if it works. If it does, I'll
probably release something very similar as a patch to bash-4.0. Bash-4.1
will do it a different way.
Chet
*** ../bash-4.0-patched/pcomplete.c 2009-03-08 21:24:31.000000000 -0400
--- pcomplete.c 2009-09-26 16:30:16.000000000 -0400
***************
*** 1176,1186 ****
WORD_LIST *ret;
char *delims;
! #if 0
! delims = "()<>;&| \t\n"; /* shell metacharacters break words */
! #else
! delims = rl_completer_word_break_characters;
! #endif
ret = split_at_delims (line, llen, delims, sentinel, nwp, cwp);
return (ret);
}
--- 1176,1188 ----
WORD_LIST *ret;
char *delims;
+ int i, j;
! delims = xmalloc (strlen (rl_completer_word_break_characters) + 1);
! for (i = j = 0; rl_completer_word_break_characters[i]; i++)
! if (rl_completer_word_break_characters[i] != '\'' &&
rl_completer_word_break_characters[i] != '"')
! delims[j++] = rl_completer_word_break_characters[i];
! delims[j] = '\0';
ret = split_at_delims (line, llen, delims, sentinel, nwp, cwp);
+ free (delims);
return (ret);
}
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/