Merge lp:~jjo/bash-completion/quote_readline_by_ref_fixes into lp:ubuntu/trusty/bash-completion

Proposed by JuanJo Ciarlante on 2014-03-13
Status: Merged
Merge reported by: Luke Yelavich
Merged at revision: not available
Proposed branch: lp:~jjo/bash-completion/quote_readline_by_ref_fixes
Merge into: lp:ubuntu/trusty/bash-completion
Diff against target: 80 lines (+42/-1)
4 files modified
.pc/applied-patches (+1/-0)
bash_completion (+11/-1)
debian/patches/quote_readline_by_ref_fixes.patch (+29/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~jjo/bash-completion/quote_readline_by_ref_fixes
Reviewer Review Type Date Requested Status
Luke Yelavich 2014-03-13 Needs Fixing on 2014-03-13
Review via email: mp+210930@code.launchpad.net

Commit message

[jjo, r=] fix _quote_readline_by_ref to:
- avoid escaping 1st '~' (lp: #1288314)
- avoid quoting if empty, else expansion without args only shows dirs (lp: #1288031)
- replace double escaping to single (eg for completing file/paths with spaces)

To post a comment you must log in.
Luke Yelavich (themuso) wrote :

You forgot to include your patch file in your commit. I see quote_readline_by_ref_fixes.patch in debian/patches/series, but cannot find the file in the tree.

Please add the file.

Thanks for your work.

review: Needs Fixing
47. By JuanJo Ciarlante on 2014-03-13

actually add debian/patches/quote_readline_by_ref_fixes.patch

JuanJo Ciarlante (jjo) wrote :

> You forgot to include your patch file in your commit. I see
> quote_readline_by_ref_fixes.patch in debian/patches/series, but cannot find
> the file in the tree.
>
> Please add the file.
>
> Thanks for your work.

dOH! - added, thanks for the prompt review.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.pc/applied-patches'
2--- .pc/applied-patches 2014-03-09 17:38:14 +0000
3+++ .pc/applied-patches 2014-03-13 23:26:44 +0000
4@@ -3,3 +3,4 @@
5 dpkg-deb-R-add.patch
6 dpkg-ddeb.patch
7 words_bad_array_subscript.patch
8+quote_readline_by_ref_fixes.patch
9
10=== modified file 'bash_completion'
11--- bash_completion 2014-03-09 17:38:14 +0000
12+++ bash_completion 2014-03-13 23:26:44 +0000
13@@ -536,13 +536,23 @@
14 # @param $2 Name of variable to return result to
15 _quote_readline_by_ref()
16 {
17- if [[ $1 == \'* ]]; then
18+ if [ -z "$1" ]; then
19+ # avoid quoting if empty
20+ printf -v $2 %s "$1"
21+ elif [[ $1 == \'* ]]; then
22 # Leave out first character
23 printf -v $2 %s "${1:1}"
24+ elif [[ $1 == ~* ]]; then
25+ # avoid escaping first ~
26+ printf -v $2 ~%q "${1:1}"
27 else
28 printf -v $2 %q "$1"
29 fi
30
31+ # Replace double escaping ( \\ ) by single ( \ )
32+ # This happens always when argument is already escaped at cmdline,
33+ # and passed to this function as e.g.: file\ with\ spaces
34+ [[ ${!2} == *\\* ]] && printf -v $2 %s "${1//\\\\/\\}"
35 # If result becomes quoted like this: $'string', re-evaluate in order to
36 # drop the additional quoting. See also: http://www.mail-archive.com/
37 # bash-completion-devel@lists.alioth.debian.org/msg01942.html
38
39=== added file 'debian/patches/quote_readline_by_ref_fixes.patch'
40--- debian/patches/quote_readline_by_ref_fixes.patch 1970-01-01 00:00:00 +0000
41+++ debian/patches/quote_readline_by_ref_fixes.patch 2014-03-13 23:26:44 +0000
42@@ -0,0 +1,29 @@
43+Index: bash-completion/bash_completion
44+===================================================================
45+--- bash-completion.orig/bash_completion 2014-03-13 19:40:27.329251000 -0300
46++++ bash-completion/bash_completion 2014-03-13 19:41:29.363721903 -0300
47+@@ -536,13 +536,23 @@
48+ # @param $2 Name of variable to return result to
49+ _quote_readline_by_ref()
50+ {
51+- if [[ $1 == \'* ]]; then
52++ if [ -z "$1" ]; then
53++ # avoid quoting if empty
54++ printf -v $2 %s "$1"
55++ elif [[ $1 == \'* ]]; then
56+ # Leave out first character
57+ printf -v $2 %s "${1:1}"
58++ elif [[ $1 == ~* ]]; then
59++ # avoid escaping first ~
60++ printf -v $2 ~%q "${1:1}"
61+ else
62+ printf -v $2 %q "$1"
63+ fi
64+
65++ # Replace double escaping ( \\ ) by single ( \ )
66++ # This happens always when argument is already escaped at cmdline,
67++ # and passed to this function as e.g.: file\ with\ spaces
68++ [[ ${!2} == *\\* ]] && printf -v $2 %s "${1//\\\\/\\}"
69+ # If result becomes quoted like this: $'string', re-evaluate in order to
70+ # drop the additional quoting. See also: http://www.mail-archive.com/
71+ # bash-completion-devel@lists.alioth.debian.org/msg01942.html
72
73=== modified file 'debian/patches/series'
74--- debian/patches/series 2014-03-09 17:38:14 +0000
75+++ debian/patches/series 2014-03-13 23:26:44 +0000
76@@ -3,3 +3,4 @@
77 dpkg-deb-R-add.patch
78 dpkg-ddeb.patch
79 words_bad_array_subscript.patch
80+quote_readline_by_ref_fixes.patch

Subscribers

People subscribed via source and target branches