[Bash-completion-devel] Bug#619548: bash-completion: files are missing from list of candidate filenames after tar zcvf
Omer Zak
w1 at zak.co.il
Thu Mar 24 22:04:51 UTC 2011
Package: bash-completion
Version: 1:1.2-3
Severity: normal
NOTE: The attached /etc/bash_completion.d/tar fixes the bug by
commenting out the code which invokes the _tar function.
The bug exists when working with the /etc/bash_completion.d/tar file
installed by the package.
The bug is that when I start a 'tar zcvf tarfile.tgz ' command and want
to add filenames by tab-completing as much as possible, some files do
not appear in the lists of candidate files. So I have to type out the
full filename rather than do tab-completion on that filename.
I saw the bug also in Debian Lenny and fixed it there the same way.
-- System Information:
Debian Release: 6.0.1
APT prefers squeeze-updates
APT policy: (500, 'squeeze-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-5-vserver-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages bash-completion depends on:
ii bash 4.1-3 The GNU Bourne Again SHell
bash-completion recommends no packages.
bash-completion suggests no packages.
-- Configuration Files:
/etc/bash_completion.d/tar changed:
have tar && {
_tar()
{
local cur ext regex tar untar
COMPREPLY=()
_get_comp_words_by_ref cur
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W 'c t x u r d A' -- "$cur" ) )
return 0
fi
case ${COMP_WORDS[1]} in
?(-)[cr]*f)
_filedir
return 0
;;
+([^IZzJjy])f)
ext='t@(ar?(.@(Z|gz|bz?(2)|lz?(ma)|xz))|gz|bz?(2)|lz?(ma)|xz)'
regex='t\(ar\(\.\(Z\|gz\|bz2\?\|lzma\|xz\)\)\?\|gz\|bz2\?\|lzma\|xz\)'
;;
*[Zz]*f)
ext='t?(ar.)@(gz|Z)'
regex='t\(ar\.\)\?\(gz\|Z\)'
;;
*[Ijy]*f)
ext='t?(ar.)bz?(2)'
regex='t\(ar\.\)\?bz2\?'
;;
*[J]*f)
ext='t?(ar.)@(lz?(ma)|xz)'
regex='t\(ar\.\)\?\(lzma\|xz\)\?'
;;
*)
_filedir
return 0
;;
esac
if [[ "$COMP_LINE" == *$ext' ' ]]; then
# complete on files in tar file
#
# get name of tar file from command line
tar=$( sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' <<<"$COMP_LINE" )
# devise how to untar and list it
untar=t${COMP_WORDS[1]//[^Izjyf]/}
COMPREPLY=( $( compgen -W "$( printf '%s ' $( tar $untar $tar \
2>/dev/null ) )" -- "$cur" ) )
return 0
fi
# file completion on relevant files
_filedir "$ext"
return 0
}
}
-- no debconf information
More information about the Bash-completion-devel
mailing list