------------------------------------------------------------
revno: 46
tags: 1:2.1-2ubuntu4
fixes bugs: https://launchpad.net/bugs/1288314 https://launchpad.net/bugs/1288031
author: JuanJo Ciarlante <jjo@canonical.com>
committer: Package Import Robot <package-import@ubuntu.com>
branch nick: trusty-proposed
timestamp: Thu 2014-03-13 16:43:22 -0300
message:
  * 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)
diff:
=== modified file '.pc/applied-patches'
--- .pc/applied-patches	2014-03-09 17:38:14 +0000
+++ .pc/applied-patches	2014-03-13 19:43:22 +0000
@@ -3,3 +3,4 @@
 dpkg-deb-R-add.patch
 dpkg-ddeb.patch
 words_bad_array_subscript.patch
+quote_readline_by_ref_fixes.patch

=== added directory '.pc/quote_readline_by_ref_fixes.patch'
=== modified file 'bash_completion'
--- bash_completion	2014-03-09 17:38:14 +0000
+++ bash_completion	2014-03-13 19:43:22 +0000
@@ -536,13 +536,23 @@
 # @param $2  Name of variable to return result to
 _quote_readline_by_ref()
 {
-    if [[ $1 == \'* ]]; then
+    if [ -z "$1" ]; then
+        # avoid quoting if empty
+        printf -v $2 %s "$1"
+    elif [[ $1 == \'* ]]; then
         # Leave out first character
         printf -v $2 %s "${1:1}"
+    elif [[ $1 == ~* ]]; then
+        # avoid escaping first ~
+        printf -v $2 ~%q "${1:1}"
     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-devel@lists.alioth.debian.org/msg01942.html

=== modified file 'debian/changelog'
--- debian/changelog	2014-03-09 17:38:14 +0000
+++ debian/changelog	2014-03-13 19:43:22 +0000
@@ -1,3 +1,14 @@
+bash-completion (1:2.1-2ubuntu4) trusty; urgency=medium
+
+  * 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)
+
+ -- JuanJo Ciarlante <jjo@canonical.com>  Thu, 13 Mar 2014 19:43:22 -0300
+
 bash-completion (1:2.1-2ubuntu3) trusty; urgency=medium
 
   * debian/patches/words_bad_array_subscript.patch

=== added file 'debian/patches/quote_readline_by_ref_fixes.patch'
--- debian/patches/quote_readline_by_ref_fixes.patch	1970-01-01 00:00:00 +0000
+++ debian/patches/quote_readline_by_ref_fixes.patch	2014-03-13 19:43:22 +0000
@@ -0,0 +1,29 @@
+Index: bash-completion/bash_completion
+===================================================================
+--- bash-completion.orig/bash_completion	2014-03-13 19:40:27.329251000 -0300
++++ bash-completion/bash_completion	2014-03-13 19:41:29.363721903 -0300
+@@ -536,13 +536,23 @@
+ # @param $2  Name of variable to return result to
+ _quote_readline_by_ref()
+ {
+-    if [[ $1 == \'* ]]; then
++    if [ -z "$1" ]; then
++        # avoid quoting if empty
++        printf -v $2 %s "$1"
++    elif [[ $1 == \'* ]]; then
+         # Leave out first character
+         printf -v $2 %s "${1:1}"
++    elif [[ $1 == ~* ]]; then
++        # avoid escaping first ~
++        printf -v $2 ~%q "${1:1}"
+     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-devel@lists.alioth.debian.org/msg01942.html

=== modified file 'debian/patches/series'
--- debian/patches/series	2014-03-09 17:38:14 +0000
+++ debian/patches/series	2014-03-13 19:43:22 +0000
@@ -3,3 +3,4 @@
 dpkg-deb-R-add.patch
 dpkg-ddeb.patch
 words_bad_array_subscript.patch
+quote_readline_by_ref_fixes.patch
