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

Ville Skyttä ville.skytta at iki.fi
Thu Oct 7 17:40:35 UTC 2010


The following commit has been merged in the master branch:
commit cb6a9a4dfedf7f9a45ae9f6c010b73aae2d33323
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Thu Oct 7 20:39:10 2010 +0300

    Use "compgen -f" hack from _cd() instead of emulating -o filenames in _filedir().
    
    See http://bugs.debian.org/272660#64 for more info about the hack.

diff --git a/bash_completion b/bash_completion
index 5c6c850..b2b3f1b 100644
--- a/bash_completion
+++ b/bash_completion
@@ -643,45 +643,10 @@ _filedir()
             xspec=${1:+"!*.@($1|$(printf %s $1 | tr '[:lower:]' '[:upper:]'))"}
         toks=( ${toks[@]-} $( compgen -f -X "$xspec" -- $quoted) )
         if [ ${#toks[@]} -ne 0 ]; then
-            # If `compopt' is available, set `-o filenames'
-            type compopt &>/dev/null && compopt -o filenames 2>/dev/null ||
-            # No, `compopt' isn't available;
-            # Is `-o filenames' set?
-            [[ (
-                ${COMP_WORDS[0]} && 
-                "$(complete -p ${COMP_WORDS[0]} 2>/dev/null)" == \
-                    *"-o filenames"*
-            ) ]] || {
-                # No, `-o filenames' isn't set;
-                # Emulate `-o filenames'
-                # NOTE: A side-effect of emulating `-o filenames' is that
-                #       backslash escape characters are visible within the list
-                #       of presented completions, e.g.  the completions look
-                #       like:
-                #
-                #           $ foo a<TAB>
-                #           a\ b/  a\$b/
-                #
-                #       whereas with `-o filenames' active the completions look
-                #       like:
-                #
-                #           $ ls a<TAB>
-                #           a b/  a$b/
-                #
-                for ((i=0; i < ${#toks[@]}; i++)); do
-                    # If directory exists, append slash (/)
-                    if [[ ${cur:0:1} != "'" ]]; then
-                        [[ -d ${toks[i]} ]] && toks[i]="${toks[i]}"/
-                        if [[ ${cur:0:1} == '"' ]]; then
-                            toks[i]=${toks[i]//\\/\\\\}
-                            toks[i]=${toks[i]//\"/\\\"}
-                            toks[i]=${toks[i]//\$/\\\$}
-                        else
-                            toks[i]=$(printf %q ${toks[i]})
-                        fi
-                    fi
-                done
-            }
+            # Turn on -o filenames; see http://bugs.debian.org/272660#64 for
+            # info about the compgen hack (bash < 4)
+            compopt -o filenames 2>/dev/null || \
+                compgen -f /non-existing-dir/ >/dev/null
         fi
     fi
 

-- 
bash-completion



More information about the Bash-completion-commits mailing list