[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: $2 in complete function doesn't like ':' character
From: |
Chet Ramey |
Subject: |
Re: $2 in complete function doesn't like ':' character |
Date: |
Mon, 1 Oct 2001 08:56:51 -0400 |
> > > > function _blah_complete() { echo -e "\n-$1-$2-$3-"; }
> > > > complete -F _blah_complete blah
> > > > blah arg1 arg2 arg3:and:more<TAB>
> > > -blah-more-arg2-
> > >
> > > Expected result:
> > > -blah-arg3:and:more-arg2-
> > >
> > > or even (if the ':' splits "arg3:and:more" in three words):
> > > -blah-more-and-
> >
> > `:' splits words for the completion code. The intent was to be able to
> > complete pathnames in colon-separated lists. If you quote the colon
> > with a backslash, you'll get the entire word (with backslashes intact)
> > passed to your completion function.
>
> But if that's the case, shouldn't the example given then return
> "-blah-more-and-" ???
No, because the completion code splits words like the shell does, on
unquoted metacharacters. The colon code acts within the word being
completed to allow things like the aforementioned colon-separated list.
You can get the entire word, colons included, by referencing
${COMP_WORDS[$COMP_CWORD]}
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)
Chet Ramey, CWRU chet@po.CWRU.Edu http://cnswww.cns.cwru.edu/~chet/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: $2 in complete function doesn't like ':' character,
Chet Ramey <=