The following commit has been merged in the master branch:
commit 260e2a1eeb7892daacea5294b9e3f5beb9054f60
Author: Ville Skyttä <[email protected]>
Date: Mon Dec 12 00:22:09 2011 +0200
quote: Preserve leading, trailing, and consecutive whitespace.
diff --git a/bash_completion b/bash_completion
index 0eecb15..ebebb8e 100644
--- a/bash_completion
+++ b/bash_completion
@@ -142,7 +142,8 @@ _rl_enabled()
# This function shell-quotes the argument
quote()
{
- echo \'${1//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
+ local quoted=${1//\'/\'\\\'\'}
+ printf "'%s'" "$quoted"
}
# @see _quote_readline_by_ref()
diff --git a/test/unit/quote.exp b/test/unit/quote.exp
new file mode 100644
index 0000000..afe670a
--- /dev/null
+++ b/test/unit/quote.exp
@@ -0,0 +1,69 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+set cmd {quote "a b"}
+set test {quote "a b" should output 'a b'}
+send "$cmd\r"
+expect -ex "$cmd\r\n"
+expect {
+ -re {'a b'} { pass $test }
+ default { fail $test }
+}
+sync_after_int
+
+
+set cmd {quote "a b"}
+set test {quote "a b" should output 'a b'}
+send "$cmd\r"
+expect -ex "$cmd\r\n"
+expect {
+ -re {'a b'} { pass $test }
+ default { fail $test }
+}
+sync_after_int
+
+
+set cmd {quote " a "}
+set test {quote " a " should output ' a '}
+send "$cmd\r"
+expect -ex "$cmd\r\n"
+expect {
+ -re {' a '} { pass $test }
+ default { fail $test }
+}
+sync_after_int
+
+
+set cmd {quote "a'b'c"}
+set test {quote "a'b'c" should output 'a'\''b'\''c'}
+send "$cmd\r"
+expect -ex "$cmd\r\n"
+expect {
+ -re {'a'\\''b'\\''c'} { pass $test }
+ default { fail $test }
+}
+sync_after_int
+
+
+set cmd {quote "a'"}
+set test {quote "a'" should output 'a'\'''}
+send "$cmd\r"
+expect -ex "$cmd\r\n"
+expect {
+ -re {'a'\\'''} { pass $test }
+ default { fail $test }
+}
+sync_after_int
+
+
+teardown
--
bash-completion
_______________________________________________
Bash-completion-commits mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/bash-completion-commits