summaryrefslogtreecommitdiff
path: root/debian/patches/14-bug-550676-fallback-to-path-completion.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/14-bug-550676-fallback-to-path-completion.patch')
-rw-r--r--debian/patches/14-bug-550676-fallback-to-path-completion.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/debian/patches/14-bug-550676-fallback-to-path-completion.patch b/debian/patches/14-bug-550676-fallback-to-path-completion.patch
new file mode 100644
index 00000000..6f51af5b
--- /dev/null
+++ b/debian/patches/14-bug-550676-fallback-to-path-completion.patch
@@ -0,0 +1,62 @@
+From: "Gabriel F. T. Gomes" <gabriel@inconstante.eti.br>
+Subject: _filedir_xspec: Fallback to suggesting all files if requested
+Origin: vendor, https://bugs.debian.org/550676
+Bug-Debian: https://bugs.debian.org/550676
+Forwarded: yes, https://github.com/scop/bash-completion/pull/260
+
+When completions generated by _filedir fail to produce an output with
+xspec, they fallback to completing without any filters, provided that
+the environment variable COMP_FILEDIR_FALLBACK is set and not-null.
+
+This patch adds the same behavior to _filedir_xspec, so that it works
+for the use case presented in message #45 in Debian bug #550676 [1],
+as suggested in message #55 [2].
+
+Before this patch, unzip completion would not complete:
+
+ $ ls[ENTER]
+ file file.ext
+
+ $ unzip [TAB][TAB][...]
+ (no output)
+
+After this patch, it completes:
+
+ $ unzip [TAB]
+ file file.ext
+
+In both cases, when a *.zip file exists, completion favours it:
+
+ $ ls[ENTER]
+ file file.ext file.zip
+
+ $ unzip [TAB]
+ $ unzip file.zip [CURSOR]
+
+[1] https://bugs.debian.org/550676#45
+[2] https://bugs.debian.org/550676#55
+---
+ bash_completion | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/bash_completion b/bash_completion
+index 546cc39b..ee65196e 100644
+--- a/bash_completion
++++ b/bash_completion
+@@ -1938,6 +1938,13 @@ _filedir_xspec()
+ }
+ ))
+
++ # Try without filter if it failed to produce anything and configured to
++ [[ -n ${COMP_FILEDIR_FALLBACK:-} && ${#toks[@]} -lt 1 ]] && {
++ local reset=$(shopt -po noglob); set -o noglob
++ toks+=( $( compgen -f -- "$(quote_readline "$cur")" ) )
++ IFS=' '; $reset; IFS=$'\n'
++ }
++
+ if [[ ${#toks[@]} -ne 0 ]]; then
+ compopt -o filenames
+ COMPREPLY=( "${toks[@]}" )
+--
+2.20.0.rc1
+