bug-bash
[Top][All Lists]
Advanced

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

Re: 4.3 compgen behavior change (quoted arg)


From: Chet Ramey
Subject: Re: 4.3 compgen behavior change (quoted arg)
Date: Wed, 13 Feb 2013 11:31:30 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130107 Thunderbird/17.0.2

On 2/13/13 5:46 AM, Raphaël Droz wrote:
> I'm not sure whether or not this is to be expected.
> 
> $ echo $BASH_VERSION 
> 4.2.42(1)-release
> $ touch a.log
> $ compgen -f -X '!*.log' -- \'\'
> $
> 
> 
> $ echo $BASH_VERSION 
> 4.3.0(3)-devel
> $ touch a.log
> $ compgen -f -X '!*.log' -- \'\'
> a.log
> $
> 
> 
> This kind of "quoted" call is used by bash-completion _filedir
> I didn't see a change notice in NEWS-4.3 about it.
> I don't know which behavior is the "correct" one.

Here's the comment associated with the change:

      /* remove backslashes quoting special characters in filenames. */
      /* There are roughtly three paths we can follow to get here:
                1.  complete -f
                2.  compgen -f "$word" from a completion function
                3.  compgen -f "$word" from the command line
         They all need to be handled.

         In the first two cases, readline will run the filename dequoting
         function in rl_filename_completion_function if it found a filename
         quoting character in the word to be completed
         (rl_completion_found_quote).  We run the dequoting function here
         if we're running compgen, we're not completing, and the
         rl_filename_completion_function won't dequote the filename
         (rl_completion_found_quote == 0). */

The idea is to make compgen, when run from the command line, more closely
emulate what it will do when run by readline via word completion.  There
are obviously heuristics involved.

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]