Package: bash-completion
Version: 1:2.8-2
Followup-For: Bug #742466

I'm attaching a debdiff of a proposed NMU for this.  I don't intend to
actually NMU unless this bug threatens not to make it into the next
Debian release (it's been around for several already :( ).

I hope this will make it easy to apply and get shipping.

This bug has been complained about for years; see, e.g.:

https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/1312243

Note that tab-completion within POSIX command substitution is still not
fully-fledged; with this fix, one gets command-name substitution after
'$(', but filename completion after entering a command does not take
place.  One has to force it manually, say with M-/.

Nevertheless this is still a huge improvement over the status quo by
preventing ugly stderr spew into the middle of the command one is
typing.

Tested with:
        Debian's bash 4.4.18-3.1
        upstream bash 5.0.0(1)-alpha

-- System Information:
Debian Release: buster/sid
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.18.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=C (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

-- no debconf information
diff -Nru bash-completion-2.8/debian/changelog 
bash-completion-2.8/debian/changelog
--- bash-completion-2.8/debian/changelog        2018-11-04 15:01:45.000000000 
-0500
+++ bash-completion-2.8/debian/changelog        2018-11-10 08:27:09.000000000 
-0500
@@ -1,3 +1,11 @@
+bash-completion (1:2.8-2.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix extremely annoying and long-standing breakage of completion
+    within POSIX command substitution $().  (Closes: #742466)
+
+ -- G. Branden Robinson <g.branden.robin...@gmail.com>  Sat, 10 Nov 2018 
08:27:09 -0500
+
 bash-completion (1:2.8-2) unstable; urgency=low
 
   * Fix for held packages completion in dpkg (Closes: #907294)
diff -Nru bash-completion-2.8/debian/patches/00-fix_quote_readline_by_ref.patch 
bash-completion-2.8/debian/patches/00-fix_quote_readline_by_ref.patch
--- bash-completion-2.8/debian/patches/00-fix_quote_readline_by_ref.patch       
2018-11-04 13:14:10.000000000 -0500
+++ bash-completion-2.8/debian/patches/00-fix_quote_readline_by_ref.patch       
2018-11-10 08:26:27.000000000 -0500
@@ -9,13 +9,23 @@
 Bug-Debian: https://bugs.debian.org/739835
 Forwarded: yes, <5328f418....@canonical.com>
 
+From: G. Branden Robinson <g.branden.robin...@gmail.com>
+Subject: Revert "double escaping" hunk of patch.
+ - That portion fixed no cited bug.
+ - It broke extremely common command-substitution cases, e.g.
+     "grep pattern $(<TAB>)", producing:
+     bash: unexpected EOF while looking for matching `)'
+     bash: syntax error: unexpected end of file
+Origin: vendor, https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742466
+Bug-Debian: https://bugs.debian.org/742466
+
 ---
  bash_completion |   13 ++++++++++++-
  1 file changed, 12 insertions(+), 1 deletion(-)
 
---- bash-completion.orig/bash_completion
-+++ bash-completion/bash_completion
-@@ -536,13 +536,24 @@ __ltrim_colon_completions()
+--- a/bash_completion
++++ b/bash_completion
+@@ -526,9 +526,15 @@
  # @param $2  Name of variable to return result to
  _quote_readline_by_ref()
  {
@@ -32,12 +42,3 @@
      else
          printf -v $2 %q "$1"
      fi
- 
-+    # Replace double escaping ( \\ ) by single ( \ )
-+    # This happens always when argument is already escaped at cmdline,
-+    # and passed to this function as e.g.: file\ with\ spaces
-+    [[ ${!2} == *\\* ]] && printf -v $2 %s "${1//\\\\/\\}"
-+
-     # If result becomes quoted like this: $'string', re-evaluate in order to
-     # drop the additional quoting.  See also: http://www.mail-archive.com/
-     # bash-completion-de...@lists.alioth.debian.org/msg01942.html

Reply via email to