[Bash-completion-devel] Bug#521407: bash-completion: no completion for ls with variables
David Paleino
d.paleino at gmail.com
Sat Apr 4 20:55:22 UTC 2009
On Sat, 4 Apr 2009 22:49:26 +0200, David Paleino wrote:
> _longopt() {
> [..]
> if [[ "$cur" == -* ]]; then
> [..]
> elif [[ $(dequote "$cur") == "\$"* ]]; then
> COMPREPLY=( $( compgen -v -P '$' -- "${cur//\$/}" ) )
> elif [[ "$1" == rmdir ]]; then
> [..]
> }
>
> that doesn't work because the $ gets escaped, so one ends up with "ls
> \$OLDPWD", which doesn't work (obviously). I'm too tired to dig into the code,
> so if someone knows the reason why, is welcome :)
Ooookay, I found a similar snippet in _cd(), and that works :)
# try to allow variable completion
if [[ "$cur" == ?(\\)\$* ]]; then
COMPREPLY=( $( compgen -v -P '$' -- "${cur#?(\\)$}" ) )
return 0
fi
However it still conflicts with -o filenames (!!! I wrote this without even
thinking. Is it really the culprit for escaping $?! Wow.)
Ideas?
David
--
. ''`. Debian maintainer | http://wiki.debian.org/DavidPaleino
: :' : Linuxer #334216 --|-- http://www.hanskalabs.net/
`. `'` GPG: 1392B174 ----|---- http://snipr.com/qa_page
`- 2BAB C625 4E66 E7B8 450A C3E1 E6AA 9017 1392 B174
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20090404/6ff54a78/attachment.pgp
More information about the Bash-completion-devel
mailing list