[Top][All Lists]

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

Re: compgen -f failing on directory containing single quote

From: Chet Ramey
Subject: Re: compgen -f failing on directory containing single quote
Date: Sun, 13 Dec 2009 17:23:12 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv: Gecko/20091204 Thunderbird/3.0

On 12/13/09 5:07 AM, Freddy Vulto wrote:
> `compgen -f' produces no output if the directory contains a single quote.
> I get the same result on both bash-3.2.39 and bash-4.0.35.
> Steps to reproduce the problem:
>     $ mkdir a\'b
>     $ touch a\'b/{c,d}
>     $ compgen -f a\'b/
>     $
> Expected output:
>     a\'b/c
>     a\'b/d

The last time this came up, I wrote:

For historical reasons, complete/compgen dequote the filename they're
passed, removing backslash escapes and interpreting embedded quoted
substrings.  (One of the things bash should do when it does that is to
be better about obeying the shell rules about backslash-escaped characters
and double quotes, but that doesn't matter for this example -- though that
function has several problems.)

When it's called as the result of readline dispatching on a particular
character, this is appropriate -- the shell hasn't done any expansion
or quote removal, so the filenames still have embedded quoting.  When
called from the command line, as in these examples, it's not appropriate,
since the shell has already expanded the argument and stripped the


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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