[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 0f450219b667ec5f8d951b0c41593c7b983e2ada

Ville Skyttä ville.skytta at iki.fi
Mon Nov 1 17:30:52 UTC 2010


The following commit has been merged in the master branch:
commit 0f450219b667ec5f8d951b0c41593c7b983e2ada
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Mon Nov 1 19:26:53 2010 +0200

    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.

diff --git a/CHANGES b/CHANGES
index 21d7bf9..cee60a9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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)
diff --git a/bash_completion b/bash_completion
index 4f853be..de9daef 100644
--- a/bash_completion
+++ b/bash_completion
@@ -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
 
diff --git a/completions/_mock b/completions/_mock
index c1888ed..fa31271 100644
--- a/completions/_mock
+++ b/completions/_mock
@@ -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
diff --git a/completions/_subversion b/completions/_subversion
index 4ffe1ea..91523d8 100644
--- a/completions/_subversion
+++ b/completions/_subversion
@@ -216,7 +216,7 @@ _svn()
 
     return 0
 }
-complete -F _svn -o filenames svn
+complete -F _svn svn
 
 _svnadmin()
 {
diff --git a/completions/_yum b/completions/_yum
index 19b79ce..9d3cbb6 100644
--- a/completions/_yum
+++ b/completions/_yum
@@ -146,7 +146,7 @@ _yum()
     fi
 }
 } &&
-complete -F _yum -o filenames yum
+complete -F _yum yum
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/_yum-utils b/completions/_yum-utils
index 49a57f7..b7f6d26 100644
--- a/completions/_yum-utils
+++ b/completions/_yum-utils
@@ -20,7 +20,7 @@ _repomanage()
         _filedir -d
     fi
 } &&
-complete -F _repomanage -o filenames repomanage
+complete -F _repomanage repomanage
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/abook b/completions/abook
index 2a3bc4f..f09c8b5 100644
--- a/completions/abook
+++ b/completions/abook
@@ -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
diff --git a/completions/ant b/completions/ant
index e0d835d..132c439 100644
--- a/completions/ant
+++ b/completions/ant
@@ -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:
diff --git a/completions/apt b/completions/apt
index 4010a0d..84811ae 100644
--- a/completions/apt
+++ b/completions/apt
@@ -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
diff --git a/completions/apt-build b/completions/apt-build
index 9597ae8..d875a98 100644
--- a/completions/apt-build
+++ b/completions/apt-build
@@ -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
diff --git a/completions/aspell b/completions/aspell
index e063f49..5254eee 100644
--- a/completions/aspell
+++ b/completions/aspell
@@ -84,7 +84,7 @@ _aspell()
     fi
 
 }
-complete -F _aspell -o filenames aspell
+complete -F _aspell aspell
 }
 
 # Local variables:
diff --git a/completions/bzip2 b/completions/bzip2
index be03027..7e2f9fd 100644
--- a/completions/bzip2
+++ b/completions/bzip2
@@ -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
diff --git a/completions/configure b/completions/configure
index e8a78ff..1b20769 100644
--- a/completions/configure
+++ b/completions/configure
@@ -33,7 +33,7 @@ _configure()
             -- "$cur" ) )
     fi
 }
-complete -F _configure -o filenames configure
+complete -F _configure configure
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/coreutils b/completions/coreutils
index 75ebaac..299aabe 100644
--- a/completions/coreutils
+++ b/completions/coreutils
@@ -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
 #
diff --git a/completions/cpio b/completions/cpio
index e77b415..5ead018 100644
--- a/completions/cpio
+++ b/completions/cpio
@@ -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:
diff --git a/completions/crontab b/completions/crontab
index cc279f8..d2ee23a 100644
--- a/completions/crontab
+++ b/completions/crontab
@@ -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
diff --git a/completions/cups b/completions/cups
index 80c9af5..2848c95 100644
--- a/completions/cups
+++ b/completions/cups
@@ -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
diff --git a/completions/dd b/completions/dd
index 5b952b4..7b9b3ac 100644
--- a/completions/dd
+++ b/completions/dd
@@ -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
diff --git a/completions/dpkg b/completions/dpkg
index a70ccef..0556f3d 100644
--- a/completions/dpkg
+++ b/completions/dpkg
@@ -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
diff --git a/completions/dselect b/completions/dselect
index e33e5bd..3042a8d 100644
--- a/completions/dselect
+++ b/completions/dselect
@@ -29,7 +29,7 @@ _dselect()
 
     return 0
 } &&
-complete -F _dselect -o filenames dselect
+complete -F _dselect dselect
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/e2fsprogs b/completions/e2fsprogs
index 15d9175..50ce788 100644
--- a/completions/e2fsprogs
+++ b/completions/e2fsprogs
@@ -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
diff --git a/completions/findutils b/completions/findutils
index 6af5d50..b8aaa57 100644
--- a/completions/findutils
+++ b/completions/findutils
@@ -117,7 +117,7 @@ _find()
 
     return 0
 } &&
-complete -F _find -o filenames find
+complete -F _find find
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/fuse b/completions/fuse
index b4d80a2..58d0c51 100644
--- a/completions/fuse
+++ b/completions/fuse
@@ -25,7 +25,7 @@ _fusermount()
         _filedir -d
     fi
 } &&
-complete -F _fusermount -o filenames fusermount
+complete -F _fusermount fusermount
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/gcc b/completions/gcc
index 3f5a561..d78e3e2 100644
--- a/completions/gcc
+++ b/completions/gcc
@@ -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
diff --git a/completions/gdb b/completions/gdb
index dc76961..f0bc42d 100644
--- a/completions/gdb
+++ b/completions/gdb
@@ -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'
diff --git a/completions/genisoimage b/completions/genisoimage
index 7f37904..61b1811 100644
--- a/completions/genisoimage
+++ b/completions/genisoimage
@@ -66,7 +66,7 @@ _mkisofs()
     fi
 
 } &&
-complete -F _mkisofs -o filenames mkisofs genisoimage
+complete -F _mkisofs mkisofs genisoimage
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/gkrellm b/completions/gkrellm
index 1e3925f..13e25ad 100644
--- a/completions/gkrellm
+++ b/completions/gkrellm
@@ -43,7 +43,7 @@ _gkrellm()
     fi
 
 } &&
-complete -F _gkrellm -o filenames gkrellm gkrellm2
+complete -F _gkrellm gkrellm gkrellm2
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/gnatmake b/completions/gnatmake
index 11b0490..cdd193c 100644
--- a/completions/gnatmake
+++ b/completions/gnatmake
@@ -26,7 +26,7 @@ _gnatmake()
         _filedir '@(adb|ads)'
     fi
 } &&
-complete -F _gnatmake -o filenames gnatmake
+complete -F _gnatmake gnatmake
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/gzip b/completions/gzip
index afd647e..f7aec17 100644
--- a/completions/gzip
+++ b/completions/gzip
@@ -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
diff --git a/completions/iconv b/completions/iconv
index 14b618d..9e33200 100644
--- a/completions/iconv
+++ b/completions/iconv
@@ -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
diff --git a/completions/iftop b/completions/iftop
index eefcf9c..9ec2a0d 100644
--- a/completions/iftop
+++ b/completions/iftop
@@ -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
diff --git a/completions/imagemagick b/completions/imagemagick
index 5366e61..c7ba74c 100644
--- a/completions/imagemagick
+++ b/completions/imagemagick
@@ -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:
diff --git a/completions/info b/completions/info
index 55791d3..367cade 100644
--- a/completions/info
+++ b/completions/info
@@ -47,7 +47,7 @@ _info()
 
     return 0
 } &&
-complete -F _info -o filenames info
+complete -F _info info
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/ipmitool b/completions/ipmitool
index 7af8da8..3a90eeb 100644
--- a/completions/ipmitool
+++ b/completions/ipmitool
@@ -203,7 +203,7 @@ _ipmitool()
 }
 
 } &&
-complete -F _ipmitool -o filenames ipmitool
+complete -F _ipmitool ipmitool
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/ipv6calc b/completions/ipv6calc
index 75f55e7..20e810d 100644
--- a/completions/ipv6calc
+++ b/completions/ipv6calc
@@ -46,7 +46,7 @@ _ipv6calc()
 
     return 0
 } &&
-complete -F _ipv6calc -o filenames ipv6calc
+complete -F _ipv6calc ipv6calc
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/jar b/completions/jar
index 6abfff3..f60eb3e 100644
--- a/completions/jar
+++ b/completions/jar
@@ -25,7 +25,7 @@ _jar()
             ;;
     esac
 } &&
-complete -F _jar -o filenames jar
+complete -F _jar jar
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/java b/completions/java
index 5be7ad2..fcdc572 100644
--- a/completions/java
+++ b/completions/java
@@ -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
diff --git a/completions/k3b b/completions/k3b
index a2b0af6..1965717 100644
--- a/completions/k3b
+++ b/completions/k3b
@@ -44,7 +44,7 @@ _k3b()
         _filedir
     fi
 } &&
-complete -F _k3b -o filenames k3b
+complete -F _k3b k3b
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/kldload b/completions/kldload
index a230dbb..e5bce0a 100644
--- a/completions/kldload
+++ b/completions/kldload
@@ -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
 
 }
 
diff --git a/completions/lftp b/completions/lftp
index 15d0a97..1de87ae 100644
--- a/completions/lftp
+++ b/completions/lftp
@@ -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()
 {
diff --git a/completions/links b/completions/links
index 4b5c683..9b7b50f 100644
--- a/completions/links
+++ b/completions/links
@@ -32,7 +32,7 @@ _links()
 
     return 0
 } &&
-complete -F _links -o filenames links
+complete -F _links links
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/lintian b/completions/lintian
index a1f5154..e223789 100644
--- a/completions/lintian
+++ b/completions/lintian
@@ -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
 }
diff --git a/completions/lrzip b/completions/lrzip
index 445fc3c..5cde88a 100644
--- a/completions/lrzip
+++ b/completions/lrzip
@@ -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
diff --git a/completions/lzma b/completions/lzma
index c2fece9..295ef37 100644
--- a/completions/lzma
+++ b/completions/lzma
@@ -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
diff --git a/completions/lzop b/completions/lzop
index 7a34ae3..6d38412 100644
--- a/completions/lzop
+++ b/completions/lzop
@@ -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
diff --git a/completions/mailman b/completions/mailman
index 3322789..b239cbb 100644
--- a/completions/mailman
+++ b/completions/mailman
@@ -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()
diff --git a/completions/make b/completions/make
index e792b34..76e9528 100644
--- a/completions/make
+++ b/completions/make
@@ -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
diff --git a/completions/man b/completions/man
index 6918fb4..9e5cd3a 100644
--- a/completions/man
+++ b/completions/man
@@ -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
diff --git a/completions/mc b/completions/mc
index 910fef1..09e9eab 100644
--- a/completions/mc
+++ b/completions/mc
@@ -36,7 +36,7 @@ _mc()
         _filedir -d
     fi
 } &&
-complete -F _mc -o filenames mc
+complete -F _mc mc
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/mcrypt b/completions/mcrypt
index 9e746fb..32c4f89 100644
--- a/completions/mcrypt
+++ b/completions/mcrypt
@@ -73,7 +73,7 @@ _mcrypt()
         fi
     fi
 } &&
-complete -o filenames -F _mcrypt mcrypt mdecrypt
+complete -F _mcrypt mcrypt mdecrypt
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/module-init-tools b/completions/module-init-tools
index 8c0f13e..bf2d24d 100644
--- a/completions/module-init-tools
+++ b/completions/module-init-tools
@@ -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
diff --git a/completions/monodevelop b/completions/monodevelop
index 1aa117b..69b2344 100644
--- a/completions/monodevelop
+++ b/completions/monodevelop
@@ -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
diff --git a/completions/mplayer b/completions/mplayer
index 1009486..ed5ab92 100644
--- a/completions/mplayer
+++ b/completions/mplayer
@@ -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:
diff --git a/completions/mutt b/completions/mutt
index f86e675..b8124f2 100644
--- a/completions/mutt
+++ b/completions/mutt
@@ -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:
diff --git a/completions/mysqladmin b/completions/mysqladmin
index a7e002d..c941569 100644
--- a/completions/mysqladmin
+++ b/completions/mysqladmin
@@ -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
diff --git a/completions/perl b/completions/perl
index 55d07cf..dc71742 100644
--- a/completions/perl
+++ b/completions/perl
@@ -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
 }
diff --git a/completions/postfix b/completions/postfix
index d9de61d..1311c98 100644
--- a/completions/postfix
+++ b/completions/postfix
@@ -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:
diff --git a/completions/postgresql b/completions/postgresql
index 392c9aa..d42d6e1 100644
--- a/completions/postgresql
+++ b/completions/postgresql
@@ -151,7 +151,7 @@ _psql()
         _pg_databases
     fi
 }
-complete -F _psql -o filenames psql
+complete -F _psql psql
 }
 
 # Local variables:
diff --git a/completions/povray b/completions/povray
index 7abc497..a843a5c 100644
--- a/completions/povray
+++ b/completions/povray
@@ -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
diff --git a/completions/python b/completions/python
index 4bcaa4c..54a99da 100644
--- a/completions/python
+++ b/completions/python
@@ -45,7 +45,7 @@ _python()
 
     return 0
 } &&
-complete -F _python -o filenames python
+complete -F _python python
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/qemu b/completions/qemu
index ca4e318..03fa563 100644
--- a/completions/qemu
+++ b/completions/qemu
@@ -121,7 +121,7 @@ _qemu()
         _filedir
     fi
 } &&
-complete -F _qemu -o filenames qemu
+complete -F _qemu qemu
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/rcs b/completions/rcs
index 42ac8d5..d859b8a 100644
--- a/completions/rcs
+++ b/completions/rcs
@@ -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
diff --git a/completions/reportbug b/completions/reportbug
index 51e37fb..0c44bd6 100644
--- a/completions/reportbug
+++ b/completions/reportbug
@@ -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
diff --git a/completions/rpm b/completions/rpm
index 9bd19f6..f07ba7d 100644
--- a/completions/rpm
+++ b/completions/rpm
@@ -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:
diff --git a/completions/sbcl b/completions/sbcl
index 2daf65e..33671a6 100644
--- a/completions/sbcl
+++ b/completions/sbcl
@@ -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
diff --git a/completions/sh b/completions/sh
index f33705d..9c7ca02 100644
--- a/completions/sh
+++ b/completions/sh
@@ -30,7 +30,7 @@ _sh()
 
     _filedir sh
 } &&
-complete -F _sh -o filenames sh
+complete -F _sh sh
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/shadow b/completions/shadow
index ea265a3..6aea045 100644
--- a/completions/shadow
+++ b/completions/shadow
@@ -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()
diff --git a/completions/sqlite3 b/completions/sqlite3
index f02b2e0..b37c55f 100644
--- a/completions/sqlite3
+++ b/completions/sqlite3
@@ -28,7 +28,7 @@ _sqlite3()
 
     _filedir $dbexts
 } &&
-complete -F _sqlite3 -o filenames sqlite3
+complete -F _sqlite3 sqlite3
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/ssh b/completions/ssh
index 2c20c2d..6793ddf 100644
--- a/completions/ssh
+++ b/completions/ssh
@@ -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:
diff --git a/completions/svk b/completions/svk
index c809d2e..bda5997 100644
--- a/completions/svk
+++ b/completions/svk
@@ -214,7 +214,7 @@ _svk()
 
     return 0
 } &&
-complete -F _svk -o filenames svk
+complete -F _svk svk
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/tar b/completions/tar
index 44c6b45..fba25d6 100644
--- a/completions/tar
+++ b/completions/tar
@@ -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:
diff --git a/completions/unace b/completions/unace
index 73d635d..9d27ef5 100644
--- a/completions/unace
+++ b/completions/unace
@@ -18,7 +18,7 @@ _unace()
         fi
     fi
 } &&
-complete -F _unace -o filenames unace
+complete -F _unace unace
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/unrar b/completions/unrar
index 0f5f709..0a4fe27 100644
--- a/completions/unrar
+++ b/completions/unrar
@@ -21,7 +21,7 @@ _unrar()
     fi
 
 } &&
-complete -F _unrar -o filenames unrar
+complete -F _unrar unrar
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/wtf b/completions/wtf
index 2b6c4d0..a611978 100644
--- a/completions/wtf
+++ b/completions/wtf
@@ -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
diff --git a/completions/xmllint b/completions/xmllint
index d8b5051..27ba61e 100644
--- a/completions/xmllint
+++ b/completions/xmllint
@@ -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
diff --git a/completions/xmlwf b/completions/xmlwf
index 7109bcd..74cf081 100644
--- a/completions/xmlwf
+++ b/completions/xmlwf
@@ -28,7 +28,7 @@ _xmlwf()
 
     _filedir '@(*ml|htm|svg)'
 } &&
-complete -F _xmlwf -o filenames xmlwf
+complete -F _xmlwf xmlwf
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/xmms b/completions/xmms
index 91b9ff5..662e2fa 100644
--- a/completions/xmms
+++ b/completions/xmms
@@ -19,7 +19,7 @@ _xmms()
     fi
 
 } &&
-complete -F _xmms -o filenames xmms
+complete -F _xmms xmms
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/xmodmap b/completions/xmodmap
index f4f2915..cde9e7e 100644
--- a/completions/xmodmap
+++ b/completions/xmodmap
@@ -21,7 +21,7 @@ _xmodmap()
 
     _filedir
 } &&
-complete -F _xmodmap -o filenames xmodmap
+complete -F _xmodmap xmodmap
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/xrdb b/completions/xrdb
index 423c092..7307f01 100644
--- a/completions/xrdb
+++ b/completions/xrdb
@@ -26,7 +26,7 @@ _xrdb()
 
     _filedir
 } &&
-complete -F _xrdb -o filenames xrdb
+complete -F _xrdb xrdb
 
 # Local variables:
 # mode: shell-script
diff --git a/completions/xsltproc b/completions/xsltproc
index f71d3f1..2782f80 100644
--- a/completions/xsltproc
+++ b/completions/xsltproc
@@ -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
diff --git a/completions/xz b/completions/xz
index d1765fc..89a8ac9 100644
--- a/completions/xz
+++ b/completions/xz
@@ -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
diff --git a/completions/yum-arch b/completions/yum-arch
index 3728335..bb864af 100644
--- a/completions/yum-arch
+++ b/completions/yum-arch
@@ -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
diff --git a/doc/styleguide.txt b/doc/styleguide.txt
index 4dbd573..24f2863 100644
--- a/doc/styleguide.txt
+++ b/doc/styleguide.txt
@@ -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
 ---------------
diff --git a/test/completion/acroread.exp b/test/completion/acroread.exp
index c3635ae..ccf0053 100644
--- a/test/completion/acroread.exp
+++ b/test/completion/acroread.exp
@@ -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" }
diff --git a/test/lib/completions/chown.exp b/test/lib/completions/chown.exp
index a34cbe9..bc1a8c7 100644
--- a/test/lib/completions/chown.exp
+++ b/test/lib/completions/chown.exp
@@ -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 {
diff --git a/test/lib/completions/screen.exp b/test/lib/completions/screen.exp
index a1a2013..b814589 100644
--- a/test/lib/completions/screen.exp
+++ b/test/lib/completions/screen.exp
@@ -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
diff --git a/test/lib/completions/sftp.exp b/test/lib/completions/sftp.exp
index 6505972..fecdaf1 100644
--- a/test/lib/completions/sftp.exp
+++ b/test/lib/completions/sftp.exp
@@ -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"}
 
diff --git a/test/lib/completions/ssh.exp b/test/lib/completions/ssh.exp
index 7a511ea..a5a1699 100644
--- a/test/lib/completions/ssh.exp
+++ b/test/lib/completions/ssh.exp
@@ -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

-- 
bash-completion



More information about the Bash-completion-commits mailing list