Hi, On 10 Nov 2018, G. Branden Robinson wrote:
>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 :( ). It wouldn't be a problem, at all, if you submitted this as a NMU. Anyhow, thanks for bringing this up for discussion first. >I hope this will make it easy to apply and get shipping. It does, indeed. Thank you very much. >This bug has been complained about for years; see, e.g.: I'm sorry that this has been open for so long... I have been working on many ancient bugs recently, and I hope to fix many of them before the next Debian release. However, I started with those marked as important (I didn't question the reasons why a few bugs were marked as important, nor the correctness of the classification, because it predates my adoption of bash-completion). Thank you very much for raising awereness for this bug... If you know of any other bugs that deserve immediate attention, please let me know and I'll glady focus on them. >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-/. I have tested this change and it does exactly what's described above, with one addition: after the command name substitution, nor filename, nor *subcommand* substitution take place. For instance: $ echo $(cv[TAB][TAB] cvlc cvs-debi cvs-switchroot cvs cvs-debrelease cvt cvs-debc cvs-debuild cvtsudoers as expected, but: $ echo $(cvs lo[TAB][TAB] (no output) when it should have completed `log' with `log '. (This comment is just a clarification for other people reading this bug report in the future) >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. I agree and I'm preparing a new upload with this and other changes. May I attribute this change to you (as commit author) in the git repository for Debian's bash-completion. It would like like the attached patch.
>From 576b8b82134aceeed67edcc618bd29c65669ca49 Mon Sep 17 00:00:00 2001 From: "G. Branden Robinson" <g.branden.robin...@gmail.com> Date: Sat, 10 Nov 2018 12:27:21 -0200 Subject: [PATCH] Fix completion with POSIX command substitution $() Part of the fix in debian/patches/00-fix_quote_readline_by_ref.patch causes completions after `$(' to fail. This commit removes the hunk that causes the problem. --- debian/changelog | 4 +++ .../00-fix_quote_readline_by_ref.patch | 25 ++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/debian/changelog b/debian/changelog index 2e6dcfd..dc15420 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,9 @@ bash-completion (1:2.8-3) UNRELEASED; urgency=medium + [G. Branden Robinson <g.branden.robin...@gmail.com>] + * Fix extremely annoying and long-standing breakage of completion + within POSIX command substitution $(). (Closes: #742466) + -- Gabriel F. T. Gomes <gabr...@inconstante.eti.br> Sun, 04 Nov 2018 18:48:03 -0200 bash-completion (1:2.8-2) unstable; urgency=low diff --git a/debian/patches/00-fix_quote_readline_by_ref.patch b/debian/patches/00-fix_quote_readline_by_ref.patch index f96e47f..b1eeb11 100644 --- a/debian/patches/00-fix_quote_readline_by_ref.patch +++ b/debian/patches/00-fix_quote_readline_by_ref.patch @@ -9,13 +9,23 @@ Origin: vendor, https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=739835 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 @@ Forwarded: yes, <5328f418....@canonical.com> 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 -- 2.19.1