summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gabriel@inconstante.eti.br>2018-12-02 10:33:37 -0200
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>2018-12-02 10:33:37 -0200
commit87297041a8eb83a4b6fadfd64d111ee5fb6746e5 (patch)
tree24c560ca1d4b327af788b7e280ece225bcd8663b
parent5506a39b0f16cee692f44c209a0d1a3b98fa969f (diff)
downloadbash-completion-87297041a8eb83a4b6fadfd64d111ee5fb6746e5.tar.gz
Fallback to path completion in _filedir_xspec (bug #550676)
The original problem reported on bug #550676 affected version 1:1.1-1 and was fixed in version 1:1.3-1. Afterwards, commented #45 added a similar, yet different complaint [1]. Upstream developers suggested the use of COMP_FILEDIR_FALLBACK, however that doesn't work without an additional upstream fix [2]. This commit incorporates the fix into Debian. [1] https://bugs.debian.org/550676#45 [2] https://github.com/scop/bash-completion/pull/260
-rw-r--r--debian/changelog2
-rw-r--r--debian/patches/14-bug-550676-fallback-to-path-completion.patch62
-rw-r--r--debian/patches/series1
3 files changed, 65 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index a9893273..286bed8f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ bash-completion (1:2.8-5) UNRELEASED; urgency=medium
* Fix perl completions with a space between option and argument.
(Closes #614775)
+ * Fix COMP_FILEDIR_FALLBACK to address comment #45 on bug #550676
+ (https://bugs.debian.org/550676#45). (Closes: #550676)
-- Gabriel F. T. Gomes <gabriel@inconstante.eti.br> Sat, 17 Nov 2018 23:42:27 -0200
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
+
diff --git a/debian/patches/series b/debian/patches/series
index 079daa94..a8d8e0fe 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -12,4 +12,5 @@
11-add-completions-for-openrc-rc-service.patch
12-tar-support-completions-for-zstd-compression.patch
13-fix-perl-completions-with-a-space-between-option-and.patch
+14-bug-550676-fallback-to-path-completion.patch
99-use-install-data-hook.patch