[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: compgen -f failing on directory containing single quote
From: |
Freddy Vulto |
Subject: |
Re: compgen -f failing on directory containing single quote |
Date: |
Sun, 13 Dec 2009 22:23:47 +0100 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
On 091213 08:34, DennisW wrote:
Thanks for testing. Indeed on bash-4 quoting works for me as well. Adding
additional backslashes works also on bash-4:
$ echo $BASH_VERSION
4.0.35(2)-release
$ ls a*b # Make sure there's no `ab' directory
ls: cannot access a*b: No such file or directory
$ mkdir a\'b; touch a\'b/c
$ mkdir ab; touch ab/d
$ compgen -f a\'b/
ab/d # INcorrect
$ compgen -f a\\\'b/
a\'b/c # correct
I found on bash-3 the workaround is to double(triple?)-escape the quotes:
$ echo $BASH_VERSION
$ ls a*b # Make sure there's no `ab' directory
ls: cannot access a*b: No such file or directory
$ mkdir a\'b; touch a\'b/c
$ mkdir ab; touch ab/d
$ compgen -f a\'b/
ab/d # INcorrect
$ compgen -f a\\\'b/
a'b/d # INcorrect?
$ compgen -f a\\\\\'b/
a\b/d # INcorrect
$ compgen -f a\\\\\\\'b/
a\'b/d # correct
$ compgen -f "a\\\\\'b/"
So, these are the workarounds:
$ ls a\'b/ # For reference, works on both bash-3 & bash-4
c
$ compgen -f a\\\'b/ # Workaround for bash-4
a\'b/c
$ compgen -f a\\\\\\\'b/ # Workaround for bash-3
a\'b/c
Regards,
Freddy Vulto
http://fvue.nl