bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: warnings with compgen -C and -F


From: Chet Ramey
Subject: Re: warnings with compgen -C and -F
Date: Wed, 14 Oct 2015 09:59:08 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

On 10/14/15 4:08 AM, isabella parakiss wrote:
> What's the point of these two warnings in builtins/complete.def ?

To indicate to users that when you run compgen from the command line
(or complete, for that matter), you don't have the same behavior as
when you're using it from programmable completion.

The various shell variables that are set by the programmable completion
facilities will not have useful values.  If the shell function or
command uses those variables, as most do, you will not get the results
you expect, or that you would get when using programmable completion.
The man page warns about this.

Since -F and -C are intended to be used by `complete', instead of
`compgen', it's reasonable that `compgen' warn about them.  `complete'
and `compgen' accept the same set of options.

https://lists.gnu.org/archive/html/bug-bash/2014-04/msg00102.html

talks about the things you need to watch out for with -C, but doesn't
include the fact that ${COMP_WORDS} and ${COMP_CWORD} don't have
useful values.

>   if (Farg)
>     builtin_error (_("warning: -F option may not work as you expect"));
>   if (Carg)
>     builtin_error (_("warning: -C option may not work as you expect"));
> 
> Can they be removed?  It's stupid to provide a function, and warn every
> time someone uses it.

Maybe it would be better if the warning were not displayed when compgen
is being called as part of completion.  That wouldn't help with the lack
of useful shell variables though.

Chet
-- 
``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/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]