[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 48438b2061bc42e741e31a646761c7ed6c629444
Ville Skyttä
ville.skytta at iki.fi
Sun Oct 31 18:16:15 UTC 2010
The following commit has been merged in the master branch:
commit 48438b2061bc42e741e31a646761c7ed6c629444
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Sun Oct 31 20:14:56 2010 +0200
Move "compopt -o filenames" kludge to _compopt_o_filenames for easier reuse.
diff --git a/bash_completion b/bash_completion
index a3ef44a..3b477cd 100644
--- a/bash_completion
+++ b/bash_completion
@@ -608,6 +608,16 @@ _quote_readline_by_ref()
} # _quote_readline_by_ref()
+# This function turns on "-o filenames" behavior dynamically. It is present
+# for bash < 4 reasons. See http://bugs.debian.org/272660#64 for info about
+# the bash < 4 compgen hack.
+_compopt_o_filenames()
+{
+ compopt -o filenames 2>/dev/null || \
+ compgen -f /non-existing-dir/ >/dev/null
+}
+
+
# This function performs file and directory completion. It's better than
# simply using 'compgen -f', because it honours spaces in filenames.
# @param $1 If `-d', complete only on directories. Otherwise filter/pick only
@@ -644,12 +654,7 @@ _filedir()
xspec=${1:+"!*.@($1|$(printf %s $1 | tr '[:lower:]' '[:upper:]'))"}
toks=( ${toks[@]-} $( compgen -f -X "$xspec" -- $quoted) )
fi
- if [ ${#toks[@]} -ne 0 ]; then
- # 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
+ [ ${#toks[@]} -ne 0 ] && _compopt_o_filenames
COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
} # _filedir()
@@ -1343,10 +1348,7 @@ _cd()
return 0
fi
- # 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
+ _compopt_o_filenames
# Use standard dir completion if no CDPATH or parameter starts with /,
# ./ or ../
--
bash-completion
More information about the Bash-completion-commits
mailing list