Remove most "-o filenames" options to "complete".

Turn it on dynamically when needed instead; see doc/styleguide.txt for
a longer explanation.  This fixes many non-filename completions which
had been previously more or less broken due to unwanted
escape-as-filenames behavior.
This commit is contained in:
Ville Skyttä 2010-11-01 19:26:53 +02:00
parent 494c44f5a3
commit 0f450219b6
88 changed files with 160 additions and 189 deletions

View File

@ -34,6 +34,8 @@ bash-completion (2.x)
* Complete known hosts from avahi-browse only if $COMP_KNOWN_HOSTS_WITH_AVAHI
is non-empty (Alioth: #312691, RedHat: #630326).
* Improve relevance of many user/group completions, depending on context.
* Remove most "-o filenames" options to "complete", turn "-o filenames" on
dynamically when needed instead.
[ Freddy Vulto ]
* Added _tilde(), fix ~username completion (Alioth: #312613, Debian: #587095)

View File

@ -1487,6 +1487,7 @@ _command_offset()
_get_comp_words_by_ref cur
if [[ $COMP_CWORD -eq 0 ]]; then
_compopt_o_filenames
COMPREPLY=( $( compgen -c -- "$cur" ) )
else
cmd=${COMP_WORDS[0]}
@ -1525,8 +1526,8 @@ _command_offset()
[ ${#COMPREPLY[@]} -eq 0 ] && _filedir
}
complete -F _command -o filenames aoss command do else eval exec ltrace nice \
nohup padsp then time tsocks vsound xargs
complete -F _command aoss command do else eval exec ltrace nice nohup padsp \
then time tsocks vsound xargs
_root_command()
{
@ -1534,7 +1535,7 @@ _root_command()
local root_command=$1
_command $1 $2 $3
}
complete -F _root_command -o filenames fakeroot gksu gksudo kdesudo really sudo
complete -F _root_command fakeroot gksu gksudo kdesudo really sudo
# Return true if the completion should be treated as running as root
_complete_as_root()
@ -1574,16 +1575,11 @@ _longopt()
}
# makeinfo and texi2dvi are defined elsewhere.
for i in a2ps autoconf automake awk bash bc bison cat colordiff cp csplit \
curl cut date df diff dir du enscript expand fmt fold gperf gprof grep \
grub head indent irb ld ldd less ln ls m4 md5sum mkdir mkfifo mknod mv nl \
nm objcopy objdump od paste patch pr ptx readelf rm rmdir sed \
sha{,1,224,256,384,512}sum shar sort split strip tac tail tee texindex \
touch tr unexpand uniq vdir wc wget who; do
have $i && complete -F _longopt -o filenames $i
done
# These commands do not use filenames, so '-o filenames' is not needed.
for i in env netstat seq uname units; do
curl cut date df diff dir du enscript env expand fmt fold gperf gprof \
grep grub head indent irb ld ldd less ln ls m4 md5sum mkdir mkfifo mknod \
mv netstat nl nm objcopy objdump od paste patch pr ptx readelf rm rmdir \
sed seq sha{,1,224,256,384,512}sum shar sort split strip tac tail tee \
texindex touch tr uname unexpand uniq units vdir wc wget who; do
have $i && complete -F _longopt -o default $i
done
unset i
@ -1636,6 +1632,7 @@ _filedir_xspec()
}
))
[ ${#toks[@]} -ne 0 ] && _compopt_o_filenames
COMPREPLY=( "${toks[@]}" )
}
list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' "$BASH_COMPLETION" | \
@ -1657,7 +1654,7 @@ list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' "$BASH_COMPLETION" |
if [ ${#list[@]} -gt 0 ]; then
eval complete -r ${list[@]}
# install new compspecs
eval complete -F _filedir_xspec -o filenames "${list[@]}"
eval complete -F _filedir_xspec "${list[@]}"
fi
unset list

View File

@ -74,7 +74,7 @@ _mock()
_filedir '@(?(no)src.r|s)pm'
fi
} &&
complete -F _mock -o filenames mock
complete -F _mock mock
# Local variables:
# mode: shell-script

View File

@ -216,7 +216,7 @@ _svn()
return 0
}
complete -F _svn -o filenames svn
complete -F _svn svn
_svnadmin()
{

View File

@ -146,7 +146,7 @@ _yum()
fi
}
} &&
complete -F _yum -o filenames yum
complete -F _yum yum
# Local variables:
# mode: shell-script

View File

@ -20,7 +20,7 @@ _repomanage()
_filedir -d
fi
} &&
complete -F _repomanage -o filenames repomanage
complete -F _repomanage repomanage
# Local variables:
# mode: shell-script

View File

@ -26,13 +26,11 @@ _abook()
case $prev in
--informat)
[ ${BASH_VERSINFO[0]} -ge 4 ] && compopt +o filenames
COMPREPLY=( $( compgen -W "$(abook --formats | \
sed -n -e 's/^\t\([a-z]*\).*/\1/p' -e '/^$/q')" -- "$cur" ) )
return 0
;;
--outformat)
[ ${BASH_VERSINFO[0]} -ge 4 ] && compopt +o filenames
COMPREPLY=( $( compgen -W "$(abook --formats | \
sed -n -e '/^$/,$s/^\t\([a-z]*\).*/\1/p')" -- "$cur" ) )
return 0
@ -53,7 +51,7 @@ _abook()
;;
esac
} &&
complete -F _abook -o filenames abook
complete -F _abook abook
# Local variables:
# mode: shell-script

View File

@ -58,8 +58,7 @@ _ant()
fi
}
have complete-ant-cmd.pl && \
complete -C complete-ant-cmd.pl -F _ant -o filenames ant || \
complete -F _ant -o filenames ant
complete -C complete-ant-cmd.pl -F _ant ant || complete -F _ant ant
}
# Local variables:

View File

@ -71,7 +71,7 @@ _apt_get()
return 0
} &&
complete -F _apt_get -o filenames apt-get
complete -F _apt_get apt-get
# Debian apt-cache(8) completion.
#
@ -146,7 +146,7 @@ _apt_cache()
return 0
} &&
complete -F _apt_cache -o filenames apt-cache
complete -F _apt_cache apt-cache
# Local variables:
# mode: shell-script

View File

@ -55,7 +55,7 @@ _apt_build()
return 0
} &&
complete -F _apt_build -o filenames apt-build
complete -F _apt_build apt-build
# Local variables:
# mode: shell-script

View File

@ -84,7 +84,7 @@ _aspell()
fi
}
complete -F _aspell -o filenames aspell
complete -F _aspell aspell
}
# Local variables:

View File

@ -36,10 +36,11 @@ _bzip2()
_expand || return 0
_compopt_o_filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
$( compgen -d -- "$cur" ) )
} &&
complete -F _bzip2 -o filenames bzip2 pbzip2
complete -F _bzip2 bzip2 pbzip2
# Local variables:
# mode: shell-script

View File

@ -33,7 +33,7 @@ _configure()
-- "$cur" ) )
fi
}
complete -F _configure -o filenames configure
complete -F _configure configure
# Local variables:
# mode: shell-script

View File

@ -47,7 +47,7 @@ _chown()
fi
fi
} &&
complete -F _chown -o filenames chown
complete -F _chown chown
# chgrp(1) completion
@ -91,7 +91,7 @@ _chgrp()
return 0
} &&
complete -F _chgrp -o filenames chgrp
complete -F _chgrp chgrp
# id(1) completion
#

View File

@ -30,6 +30,7 @@ _cpio()
return 0
;;
--rsh-command)
_compopt_o_filenames
COMPREPLY=( $( compgen -c -- "$cur" ) )
return 0
;;
@ -90,7 +91,7 @@ _cpio()
esac
fi
}
complete -F _cpio -o filenames cpio
complete -F _cpio cpio
}
# Local variables:

View File

@ -49,7 +49,7 @@ _crontab()
# do filenames only if we did not have -l, -r, or -e
[[ "${COMP_LINE}" == *\ -@(l|r|e)* ]] || _filedir
} &&
complete -F _crontab -o filenames crontab
complete -F _crontab crontab
# Local variables:
# mode: shell-script

View File

@ -10,7 +10,7 @@ _cancel()
COMPREPLY=( $( compgen -W "$( lpstat | cut -d' ' -f1 )" -- "$cur" ) )
} &&
complete -F _cancel -o filenames cancel
complete -F _cancel cancel
# Local variables:
# mode: shell-script

View File

@ -28,7 +28,7 @@ _dd()
$( compgen -W 'bs cbs conv count ibs if obs of seek skip' \
-S '=' -- "$cur" ) )
} &&
complete -F _dd -o nospace -o filenames dd
complete -F _dd -o nospace dd
# Local variables:
# mode: shell-script

View File

@ -92,7 +92,7 @@ _dpkg()
}
complete -F _dpkg -o filenames dpkg dpkg-deb
complete -F _dpkg dpkg dpkg-deb
}
# Debian GNU dpkg-reconfigure(8) completion

View File

@ -29,7 +29,7 @@ _dselect()
return 0
} &&
complete -F _dselect -o filenames dselect
complete -F _dselect dselect
# Local variables:
# mode: shell-script

View File

@ -27,7 +27,7 @@ _badblocks()
cur=${cur:=/dev/}
_filedir
} &&
complete -F _badblocks -o filenames badblocks
complete -F _badblocks badblocks
have dumpe2fs &&
@ -55,7 +55,7 @@ _dumpe2fs()
cur=${cur:=/dev/}
_filedir
} &&
complete -F _dumpe2fs -o filenames dumpe2fs
complete -F _dumpe2fs dumpe2fs
have e2freefrag &&
@ -79,7 +79,7 @@ _e2freefrag()
cur=${cur:=/dev/}
_filedir
} &&
complete -F _e2freefrag -o filenames e2freefrag
complete -F _e2freefrag e2freefrag
have e2label &&
@ -94,7 +94,7 @@ _e2label()
_filedir
fi
} &&
complete -F _e2label -o filenames e2label
complete -F _e2label e2label
have filefrag &&
@ -111,7 +111,7 @@ _filefrag()
_filedir
} &&
complete -F _filefrag -o filenames filefrag
complete -F _filefrag filefrag
have tune2fs &&
@ -169,7 +169,7 @@ _tune2fs()
cur=${cur:=/dev/}
_filedir
} &&
complete -F _tune2fs -o filenames tune2fs
complete -F _tune2fs tune2fs
# Local variables:
# mode: shell-script

View File

@ -117,7 +117,7 @@ _find()
return 0
} &&
complete -F _find -o filenames find
complete -F _find find
# Local variables:
# mode: shell-script

View File

@ -25,7 +25,7 @@ _fusermount()
_filedir -d
fi
} &&
complete -F _fusermount -o filenames fusermount
complete -F _fusermount fusermount
# Local variables:
# mode: shell-script

View File

@ -46,9 +46,9 @@ _gcc()
_filedir
fi
} &&
complete -o filenames -F _gcc gcc g++ c++ g77 gcj gpc
complete -F _gcc gcc g++ c++ g77 gcj gpc
[ $USERLAND = GNU -o $UNAME = Cygwin ] && \
[ -n "${have:-}" ] && complete -o filenames -F _gcc cc
[ -n "${have:-}" ] && complete -F _gcc cc
# Local variables:
# mode: shell-script

View File

@ -10,6 +10,7 @@ _gdb()
if [ $COMP_CWORD -eq 1 ]; then
local IFS
_compopt_o_filenames
if [[ "$cur" == */* ]]; then
# compgen -c works as expected if $cur contains any slashes.
IFS=$'\n'

View File

@ -66,7 +66,7 @@ _mkisofs()
fi
} &&
complete -F _mkisofs -o filenames mkisofs genisoimage
complete -F _mkisofs mkisofs genisoimage
# Local variables:
# mode: shell-script

View File

@ -43,7 +43,7 @@ _gkrellm()
fi
} &&
complete -F _gkrellm -o filenames gkrellm gkrellm2
complete -F _gkrellm gkrellm gkrellm2
# Local variables:
# mode: shell-script

View File

@ -26,7 +26,7 @@ _gnatmake()
_filedir '@(adb|ads)'
fi
} &&
complete -F _gnatmake -o filenames gnatmake
complete -F _gnatmake gnatmake
# Local variables:
# mode: shell-script

View File

@ -40,10 +40,11 @@ _gzip()
_expand || return 0
_compopt_o_filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
$( compgen -d -- "$cur" ) )
} &&
complete -F _gzip -o filenames gzip pigz
complete -F _gzip gzip pigz
# Local variables:
# mode: shell-script

View File

@ -36,8 +36,6 @@ _iconv()
fi
} &&
complete -F _iconv -o default iconv
# Intentionally not -o filenames here, -f/-t completions may contain slashes
# and -o filenames would break them.
# Local variables:
# mode: shell-script

View File

@ -24,7 +24,7 @@ _iftop()
COMPREPLY=( $( compgen -W '-h -n -N -p -P -b -B -i -f -F -c -m' \
-- "$cur" ) )
} &&
complete -F _iftop -o filenames iftop
complete -F _iftop iftop
# Local variables:
# mode: shell-script

View File

@ -189,7 +189,7 @@ _convert()
_filedir
fi
}
complete -F _convert -o filenames convert
complete -F _convert convert
_mogrify()
{
@ -245,7 +245,7 @@ _mogrify()
_filedir
fi
}
complete -F _mogrify -o filenames mogrify
complete -F _mogrify mogrify
_display()
{
@ -285,7 +285,7 @@ _display()
_filedir
fi
}
complete -F _display -o filenames display
complete -F _display display
_animate()
{
@ -319,7 +319,7 @@ _animate()
_filedir
fi
}
complete -F _animate -o filenames animate
complete -F _animate animate
_identify()
{
@ -344,7 +344,7 @@ _identify()
_filedir
fi
}
complete -F _identify -o filenames identify
complete -F _identify identify
_montage()
{
@ -382,7 +382,7 @@ _montage()
_filedir
fi
}
complete -F _montage -o filenames montage
complete -F _montage montage
_composite()
{
@ -417,7 +417,7 @@ _composite()
_filedir
fi
}
complete -F _composite -o filenames composite
complete -F _composite composite
_compare()
{
@ -444,7 +444,7 @@ _compare()
_filedir
fi
}
complete -F _compare -o filenames compare
complete -F _compare compare
_conjure()
{
@ -464,7 +464,7 @@ _conjure()
_filedir
fi
}
complete -F _conjure -o filenames conjure
complete -F _conjure conjure
_import()
{
@ -495,7 +495,7 @@ _import()
_filedir
fi
}
complete -F _import -o filenames import
complete -F _import import
_stream()
{
@ -520,7 +520,7 @@ _stream()
_filedir
fi
}
complete -F _stream -o filenames stream
complete -F _stream stream
}
# Local variables:

View File

@ -47,7 +47,7 @@ _info()
return 0
} &&
complete -F _info -o filenames info
complete -F _info info
# Local variables:
# mode: shell-script

View File

@ -203,7 +203,7 @@ _ipmitool()
}
} &&
complete -F _ipmitool -o filenames ipmitool
complete -F _ipmitool ipmitool
# Local variables:
# mode: shell-script

View File

@ -46,7 +46,7 @@ _ipv6calc()
return 0
} &&
complete -F _ipv6calc -o filenames ipv6calc
complete -F _ipv6calc ipv6calc
# Local variables:
# mode: shell-script

View File

@ -25,7 +25,7 @@ _jar()
;;
esac
} &&
complete -F _jar -o filenames jar
complete -F _jar jar
# Local variables:
# mode: shell-script

View File

@ -164,7 +164,7 @@ _java()
fi
fi
}
complete -F _java -o filenames java
complete -F _java java
}
have javadoc &&
@ -217,7 +217,7 @@ _javadoc()
_java_packages
fi
} &&
complete -F _javadoc -o filenames javadoc
complete -F _javadoc javadoc
have javac &&
_javac()
@ -249,7 +249,7 @@ _javac()
_filedir java
fi
} &&
complete -F _javac -o filenames javac
complete -F _javac javac
have pack200 &&
_pack200()
@ -418,7 +418,7 @@ _jarsigner()
_filedir jar
fi
} &&
complete -F _jarsigner -o filenames jarsigner
complete -F _jarsigner jarsigner
# Local variables:
# mode: shell-script

View File

@ -44,7 +44,7 @@ _k3b()
_filedir
fi
} &&
complete -F _k3b -o filenames k3b
complete -F _k3b k3b
# Local variables:
# mode: shell-script

View File

@ -11,13 +11,14 @@ _kldload()
[ -d $moddir ] || moddir=/boot/kernel/
_get_comp_words_by_ref cur
_compopt_o_filenames
COMPREPLY=( $( compgen -f "$moddir$cur" ) )
COMPREPLY=( ${COMPREPLY[@]#$moddir} )
COMPREPLY=( ${COMPREPLY[@]%.ko} )
return 0
}
complete -F _kldload -o filenames kldload
complete -F _kldload kldload
_kldunload()
{
@ -26,7 +27,7 @@ _kldunload()
COMPREPLY=( $( kldstat | \
sed -ne "s/^.*[ \t]\{1,\}\($cur[a-z_]\{1,\}\).ko$/\1/p" ) )
}
complete -F _kldunload -o filenames kldunload
complete -F _kldunload kldunload
}

View File

@ -28,7 +28,8 @@ _lftp()
'$( cut -f 1 -s ~/.lftp/bookmarks 2>/dev/null )' -- "$cur" ) )
_known_hosts_real "$cur"
} &&
complete -F _lftp -o filenames lftp
complete -F _lftp lftp
have lftpget &&
_lftpget()
{

View File

@ -32,7 +32,7 @@ _links()
return 0
} &&
complete -F _links -o filenames links
complete -F _links links
# Local variables:
# mode: shell-script

View File

@ -181,6 +181,6 @@ _lintian_info() {
return 0
}
complete -F _lintian -o filenames lintian
complete -F _lintian_info -o filenames lintian-info
complete -F _lintian lintian
complete -F _lintian_info lintian-info
}

View File

@ -49,10 +49,11 @@ _lrzip()
_expand || return 0
local IFS=$'\n'
_compopt_o_filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
$( compgen -d -- "$cur" ) )
} &&
complete -F _lrzip -o filenames lrzip
complete -F _lrzip lrzip
# Local variables:
# mode: shell-script

View File

@ -31,10 +31,11 @@ _lzma()
_expand || return 0
_compopt_o_filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
$( compgen -d -- "$cur" ) )
} &&
complete -F _lzma -o filenames lzma
complete -F _lzma lzma
# Local variables:
# mode: shell-script

View File

@ -54,10 +54,11 @@ _lzop()
_expand || return 0
local IFS=$'\n'
_compopt_o_filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
$( compgen -d -- "$cur" ) )
} &&
complete -F _lzop -o filenames lzop
complete -F _lzop lzop
# Local variables:
# mode: shell-script

View File

@ -368,7 +368,7 @@ _config_list()
fi
} &&
complete -F _config_list -o filenames config_list
complete -F _config_list config_list
# Try to detect whether this is the mailman "arch" to avoid installing
# it for the coreutils/util-linux-ng one.
@ -416,7 +416,7 @@ _arch()
fi
} &&
complete -F _arch -o filenames arch
complete -F _arch arch
have cleanarch &&
_cleanarch()
@ -460,7 +460,7 @@ _inject()
fi
} &&
complete -F _inject -o filenames inject
complete -F _inject inject
have dumpdb &&
_dumpdb()
@ -478,7 +478,7 @@ _dumpdb()
fi
} &&
complete -F _dumpdb -o filenames dumpdb
complete -F _dumpdb dumpdb
have check_db &&
_check_db()

View File

@ -67,7 +67,7 @@ _make()
fi
} &&
complete -F _make -o filenames make gmake gnumake pmake
complete -F _make make gmake gnumake pmake
# Local variables:
# mode: shell-script

View File

@ -69,7 +69,7 @@ _man()
__ltrim_colon_completions "$cur"
return 0
} &&
complete -F _man -o filenames man apropos whatis
complete -F _man man apropos whatis
# Local variables:
# mode: shell-script

View File

@ -36,7 +36,7 @@ _mc()
_filedir -d
fi
} &&
complete -F _mc -o filenames mc
complete -F _mc mc
# Local variables:
# mode: shell-script

View File

@ -73,7 +73,7 @@ _mcrypt()
fi
fi
} &&
complete -o filenames -F _mcrypt mcrypt mdecrypt
complete -F _mcrypt mcrypt mdecrypt
# Local variables:
# mode: shell-script

View File

@ -50,7 +50,7 @@ _insmod()
return 0
} &&
complete -F _insmod -o filenames insmod modprobe modinfo
complete -F _insmod insmod modprobe modinfo
# Local variables:
# mode: shell-script

View File

@ -50,6 +50,7 @@ _mdtool()
return 0
;;
"generate-makefiles")
_compopt_o_filenames
COMPREPLY=( $( compgen -o filenames -G"*.mds" -- "$cur" ) )
if [[ "$prev" == *mds ]]; then
COMPREPLY=( $( compgen -W '--simple-makefiles --s --d:' \
@ -74,7 +75,7 @@ _mdtool()
return 0
} &&
complete -F _mdtool -o filenames mdtool
complete -F _mdtool mdtool
# Local variables:
# mode: shell-script

View File

@ -253,7 +253,7 @@ _mplayer()
return 0
}
complete -o filenames -F _mplayer mplayer mencoder gmplayer kplayer
complete -F _mplayer mplayer mencoder gmplayer kplayer
}
# Local variables:

View File

@ -120,6 +120,7 @@ _muttfiledir()
# Match any file in $folder beginning with $cur
# (minus the leading '=' sign).
_compopt_o_filenames
COMPREPLY=( $( compgen -f -- "$folder/${cur:1}" ) )
COMPREPLY=( ${COMPREPLY[@]#$folder/} )
return 0
@ -170,7 +171,7 @@ _mutt()
;;
esac
} # _mutt()
complete -F _mutt -o default -o filenames mutt muttng
complete -F _mutt -o default mutt muttng
} # have mutt
# Local variables:

View File

@ -60,7 +60,7 @@ _mysqladmin()
kill password old-password ping processlist reload refresh shutdown \
status start-slave stop-slave variables version' -- "$cur" ) )
} &&
complete -F _mysqladmin -o filenames mysqladmin
complete -F _mysqladmin mysqladmin
# Local variables:
# mode: shell-script

View File

@ -31,6 +31,7 @@ _perl()
case $prev in
-I|-x)
local IFS=$'\n'
_compopt_o_filenames
COMPREPLY=( $( compgen -d $optPrefix $optSuffix -- "$cur" ) )
return 0
;;
@ -47,7 +48,7 @@ _perl()
_filedir
fi
}
complete -F _perl -o nospace -o filenames perl
complete -F _perl -o nospace perl
complete -C ${BASH_SOURCE[0]%/*}/helpers/perldoc -o nospace -o default perldoc
}

View File

@ -29,7 +29,7 @@ _postfix()
COMPREPLY=( $( compgen -W 'check start stop abort flush reload status \
set-permissions upgrade-configuration' -- "$cur" ) )
}
complete -F _postfix -o filenames postfix
complete -F _postfix postfix
# postalias(1) and postmap(1)
#
@ -57,6 +57,7 @@ _postmap()
fi
if [[ "$cur" == *:* ]]; then
_compopt_o_filenames
COMPREPLY=( $( compgen -f -- "${cur#*:}" ) )
else
len=${#cur}
@ -68,12 +69,13 @@ _postmap()
fi
done
if [[ $idx -eq 0 ]]; then
_compopt_o_filenames
COMPREPLY=( $( compgen -f -- "$cur" ) )
fi
fi
return 0
}
complete -F _postmap -o filenames postmap postalias
complete -F _postmap postmap postalias
# postcat(1)
#
@ -116,7 +118,7 @@ _postcat()
return 0
fi
}
complete -F _postcat -o filenames postcat
complete -F _postcat postcat
# postconf(1)
#
@ -158,7 +160,7 @@ _postconf()
done
return 0
}
complete -F _postconf -o filenames postconf
complete -F _postconf postconf
# postsuper(1)
#
@ -219,7 +221,7 @@ _postsuper()
COMPREPLY=( $( compgen -W 'hold incoming active deferred' -- "$cur" ) )
}
complete -F _postsuper -o filenames postsuper
complete -F _postsuper postsuper
}
# Local variables:

View File

@ -151,7 +151,7 @@ _psql()
_pg_databases
fi
}
complete -F _psql -o filenames psql
complete -F _psql psql
}
# Local variables:

View File

@ -54,7 +54,7 @@ _povray()
;;
esac
} &&
complete -F _povray -o filenames povray xpovray spovray
complete -F _povray povray xpovray spovray
# Local variables:
# mode: shell-script

View File

@ -45,7 +45,7 @@ _python()
return 0
} &&
complete -F _python -o filenames python
complete -F _python python
# Local variables:
# mode: shell-script

View File

@ -121,7 +121,7 @@ _qemu()
_filedir
fi
} &&
complete -F _qemu -o filenames qemu
complete -F _qemu qemu
# Local variables:
# mode: shell-script

View File

@ -32,7 +32,7 @@ _rcs()
# otherwise, default to directories
[[ ${#COMPREPLY[@]} -eq 0 && $1 == ci ]] && _filedir || _filedir -d
} &&
complete -F _rcs -o filenames ci co rlog rcs rcsdiff
complete -F _rcs ci co rlog rcs rcsdiff
# Local variables:
# mode: shell-script

View File

@ -84,7 +84,7 @@ _reportbug()
_filedir
return 0
} &&
complete -F _reportbug -o filenames reportbug
complete -F _reportbug reportbug
have querybts &&
_querybts()
@ -121,7 +121,7 @@ _querybts()
www.debian.org' -- "$cur" ) \
$( apt-cache pkgnames -- "$cur" 2> /dev/null) )
} &&
complete -F _querybts -o filenames querybts
complete -F _querybts querybts
# Local variables:
# mode: shell-script

View File

@ -24,8 +24,6 @@ _rpm_installed_packages()
_rpm_groups()
{
# TODO: shown completions are wrong but real ones work nevertheless
# http://lists.alioth.debian.org/pipermail/bash-completion-devel/2009-May/001486.html
local IFS=$'\n'
COMPREPLY=( $( compgen -W "$( rpm -qa $nodig $nosig --queryformat \
'%{group}\n' )" -- "$cur" ) )
@ -101,6 +99,7 @@ _rpm()
return 0
;;
--pipe)
_compopt_o_filenames
COMPREPLY=( $( compgen -c -- "$cur" ) )
return 0
;;
@ -288,7 +287,7 @@ _rpm()
return 0
}
complete -F _rpm -o filenames rpm rpmbuild
complete -F _rpm rpm rpmbuild
}
# Local variables:

View File

@ -20,7 +20,7 @@ _sbcl()
return 0
} &&
complete -F _sbcl -o filenames sbcl sbcl-mt
complete -F _sbcl sbcl sbcl-mt
# Local variables:
# mode: shell-script

View File

@ -30,7 +30,7 @@ _sh()
_filedir sh
} &&
complete -F _sh -o filenames sh
complete -F _sh sh
# Local variables:
# mode: shell-script

View File

@ -232,7 +232,7 @@ _newusers()
_filedir
} &&
complete -F _newusers -o filenames newusers
complete -F _newusers newusers
have pwck &&
_pwck()
@ -249,7 +249,7 @@ _pwck()
_filedir
} &&
complete -F _pwck -o filenames pwck
complete -F _pwck pwck
have groupadd &&
_groupadd()
@ -390,7 +390,7 @@ _grpck()
_filedir
} &&
complete -F _grpck -o filenames grpck
complete -F _grpck grpck
have vipw || have vigr &&
_vipw()

View File

@ -28,7 +28,7 @@ _sqlite3()
_filedir $dbexts
} &&
complete -F _sqlite3 -o filenames sqlite3
complete -F _sqlite3 sqlite3
# Local variables:
# mode: shell-script

View File

@ -184,6 +184,7 @@ _ssh()
done
_known_hosts_real -a -F "$configfile" "$cur"
if [ $COMP_CWORD -ne 1 ]; then
_compopt_o_filenames
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- "$cur" ) )
fi
fi
@ -415,7 +416,7 @@ _ssh_copy_id()
return 0
}
complete -F _ssh_copy_id -o filenames ssh-copy-id
complete -F _ssh_copy_id ssh-copy-id
}
# Local variables:

View File

@ -214,7 +214,7 @@ _svk()
return 0
} &&
complete -F _svk -o filenames svk
complete -F _svk svk
# Local variables:
# mode: shell-script

View File

@ -60,7 +60,7 @@ _tar()
return 0
}
[ -n "${COMP_TAR_INTERNAL_PATHS:-}" ] && complete -F _tar -o dirnames tar ||
complete -F _tar -o filenames tar
complete -F _tar tar
}
# Local variables:

View File

@ -18,7 +18,7 @@ _unace()
fi
fi
} &&
complete -F _unace -o filenames unace
complete -F _unace unace
# Local variables:
# mode: shell-script

View File

@ -21,7 +21,7 @@ _unrar()
fi
} &&
complete -F _unrar -o filenames unrar
complete -F _unrar unrar
# Local variables:
# mode: shell-script

View File

@ -25,7 +25,7 @@ _wtf()
COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db ) -f" -- "${cur}" ) )
} &&
complete -F _wtf -o filenames wtf
complete -F _wtf wtf
# Local variables:
# mode: shell-script

View File

@ -44,7 +44,7 @@ _xmllint()
_filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl)'
} &&
complete -F _xmllint -o filenames xmllint
complete -F _xmllint xmllint
# Local variables:
# mode: shell-script

View File

@ -28,7 +28,7 @@ _xmlwf()
_filedir '@(*ml|htm|svg)'
} &&
complete -F _xmlwf -o filenames xmlwf
complete -F _xmlwf xmlwf
# Local variables:
# mode: shell-script

View File

@ -19,7 +19,7 @@ _xmms()
fi
} &&
complete -F _xmms -o filenames xmms
complete -F _xmms xmms
# Local variables:
# mode: shell-script

View File

@ -21,7 +21,7 @@ _xmodmap()
_filedir
} &&
complete -F _xmodmap -o filenames xmodmap
complete -F _xmodmap xmodmap
# Local variables:
# mode: shell-script

View File

@ -26,7 +26,7 @@ _xrdb()
_filedir
} &&
complete -F _xrdb -o filenames xrdb
complete -F _xrdb xrdb
# Local variables:
# mode: shell-script

View File

@ -45,7 +45,7 @@ _xsltproc()
_filedir '@(xsl|xslt|xml)'
fi
} &&
complete -F _xsltproc -o filenames xsltproc
complete -F _xsltproc xsltproc
# Local variables:
# mode: shell-script

View File

@ -53,10 +53,11 @@ _xz()
_expand || return 0
local IFS=$'\n'
_compopt_o_filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
$( compgen -d -- "$cur" ) )
} &&
complete -F _xz -o filenames xz
complete -F _xz xz
# xzdec(1) completion
#
@ -90,7 +91,7 @@ _xzdec()
_filedir xz # no lzma support here as of xz 4.999.9beta
} &&
complete -F _xzdec -o filenames xzdec
complete -F _xzdec xzdec
# Local variables:
# mode: shell-script

View File

@ -13,7 +13,7 @@ _yum_arch()
_filedir -d
fi
} &&
complete -F _yum_arch -o filenames yum-arch
complete -F _yum_arch yum-arch
# Local variables:
# mode: shell-script

View File

@ -54,6 +54,18 @@ is preferable because anyone, with any keyboard layout, is able to
type it. Backticks aren't always available, without doing strange
key combinations.
-o filenames
------------
As a rule of thumb, do not use "complete -o filenames". Doing it makes
it take effect for all completions from the affected function, which
may break things if some completions from the function must not be
escaped as filenames. Instead, use the _compopt_o_filenames function
to turn on "-o filenames" behavior dynamically when returning
completions that need that kind of processing (e.g. file and command
names). The _filedir and _filedir_xspec helpers do this automatically
whenever they return some completions.
/////////////////////////////////////////
case/esac vs if
---------------

View File

@ -2,7 +2,7 @@ set test "Completion via _filedir_xspec() should be installed"
set cmd "complete -p acroread"
send "$cmd\r"
set expected "^$cmd\r\ncomplete -o filenames -F _filedir_xspec acroread\r\n/@$"
set expected "^$cmd\r\ncomplete -F _filedir_xspec acroread\r\n/@$"
expect {
-re $expected { pass "$test" }
-re /@ { fail "$test at prompt" }

View File

@ -40,8 +40,7 @@ if {!$failed_find_unique_completion} {
assert_complete $fulluser:$fullgroup "chown $fulluser:$partgroup"
sync_after_int
# One slash should work correctly (doubled here for tcl).
assert_complete $fulluser\\:$fullgroup "chown $fulluser\\:$partgroup"
assert_complete "dot.user:$fullgroup" "chown dot.user:$partgroup"
sync_after_int
foreach prefix {

View File

@ -17,33 +17,8 @@ assert_complete_any "screen -"
sync_after_int
set test "-c should complete files/dirs"
set dir fixtures/shared/default
set prompt "/$dir/@"
assert_bash_exec "cd $dir" "" $prompt
set cmd "screen -c "
set expected {bar {bar bar.d} foo {foo.d}}
send "$cmd\t"
expect -ex "$cmd"
expect {
-re "\r\nbar\\s+bar bar.d/\\s+foo\\s+foo.d/" { pass "$test" }
# Directories might not be suffixed with a slash (/). This is because
# _filedir only works if `-o filenames' is in effect, which isn't the
# case for `screen' on bash-3, so an expected failure (xfail)
-re "\r\nbar\\s+bar bar.d\\s+foo\\s+foo.d" {
if {[lindex $::BASH_VERSINFO 0] < 4} {xfail "$test"} {fail "$test"}
}
-re "\r\nbar\\s+bar\\\\ bar.d/\\s+foo\\s+foo.d/" {
# On bash-3, the space in `bar bar.d' is escaped with a backslash
# as a side-effect of emulating `-o filenames'.
if {[lindex $::BASH_VERSINFO 0] <= 3} {pass "$test"} {fail "$test"}
}
-re $prompt { unresolved "$test at prompt" }
default { unresolved "$test" }
}
sync_after_int $prompt
assert_bash_exec {cd "$TESTDIR"}
assert_complete {bar "bar bar.d/" foo foo.d/} \
"screen -c fixtures/shared/default/" "-c should complete files/dirs"
sync_after_int

View File

@ -55,21 +55,10 @@ assert_complete_dir $expected "sftp -F spaced\\ \\ conf " $dir
sync_after_int
set test "-F should complete filename"
set dir fixtures/sftp
set prompt "/$dir/@"
assert_bash_exec "cd $dir" "" $prompt
set cmd "sftp -Fsp"
send "$cmd\t"
expect -ex "$cmd"
expect {
-ex "aced\\ \\ conf" { pass "$test" }
# _filedir works only if `-o filenames' is in effect, which isn't the
# case for `sftp'
-re "aced conf" { xfail "$test" }
-re $prompt { unresolved "$test at prompt" }
default { unresolved "$test" }
}
assert_complete "-Fspaced\\ \\ conf" "sftp -Fsp" "-F should complete filename"
sync_after_int $prompt
assert_bash_exec {cd "$TESTDIR"}

View File

@ -72,22 +72,9 @@ set test "-F should complete filename"
set dir fixtures/ssh
set prompt "/$dir/@"
assert_bash_exec "cd $dir" "" $prompt
set cmd "ssh -Fsp"
send "$cmd\t"
expect -ex "$cmd"
expect {
-ex "aced\\ \\ conf" { pass "$test" }
# _filedir works only if `-o filenames' is in effect, which isn't the
# case for `ssh'
-re "aced conf" { xfail "$test" }
-re $prompt { unresolved "$test at prompt" }
default { unresolved "$test" }
}
assert_complete "-Fspaced\\ \\ conf" "ssh -Fsp" "-F should complete filename"
sync_after_int $prompt
assert_bash_exec {cd "$TESTDIR"}
sync_after_int
teardown