--- bash-completion.orig/bash_completion
+++ bash-completion/bash_completion
@@ -536,13 +536,24 @@ __ltrim_colon_completions()
# @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/
# <email address hidden>/msg01942.html
The problem does not come from upstream... it it caused by a patch created by canonical. patches/ 00-fix_ quote_readline_ by_ref. patch:
debian/
From: JuanJo Ciarlante <email address hidden> readline_ by_ref to: /bugs.debian. org/cgi- bin/bugreport. cgi?bug= 739835 /bugs.debian. org/cgi- bin/bugreport. cgi?bug= 739835
Subject: fix _quote_
- 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)
Origin: vendor, https:/
Bug-Debian: https:/
Forwarded: yes, <email address hidden>
---
bash_completion | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
--- bash-completion .orig/bash_ completion /bash_completio n colon_completio ns() readline_ by_ref( )
+++ bash-completion
@@ -536,13 +536,24 @@ __ltrim_
# @param $2 Name of variable to return result to
_quote_
{
- 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 ( \ ) www.mail- archive. com/ /msg01942. html
+ # 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://
# <email address hidden>