[Bash-completion-commits] [SCM] bash-completion branch, master, updated. de585f387dc6d8e88ef1bc25452f2d706ad7e0be
Freddy Vulto
fvulto at gmail.com
Fri Sep 4 21:12:53 UTC 2009
The following commit has been merged in the master branch:
commit de585f387dc6d8e88ef1bc25452f2d706ad7e0be
Author: Freddy Vulto <fvulto at gmail.com>
Date: Fri Sep 4 23:08:56 2009 +0200
Fix _known_hosts_real() to not glob awk script
See also bugreport Alioth #311614.
Added tests for the awk script processing IP numbers. To run the tests:
cd test
./runUnit _known_hosts_real.exp
./runCompletion ssh.exp scp.exp sftp.exp
diff --git a/CHANGES b/CHANGES
index 163d047..8d61706 100644
--- a/CHANGES
+++ b/CHANGES
@@ -153,6 +153,8 @@ bash-completion (1.x)
* Added setting COMP_KNOWN_HOSTS_WITH_HOSTFILE. _known_hosts_real() will add
hosts from HOSTFILE, unless COMP_KNOWN_HOSTS_WITH_HOSTFILE is set to an
empty value (Alioth: #311821)
+ * Fix _known_hosts_real() to not glob awk script - thanks to Eric Blake
+ (Alioth #311614)
-- David Paleino <d.paleino at gmail.com> Thu, 18 Jun 2009 13:12:36 +0200
diff --git a/bash_completion b/bash_completion
index 022a7d1..c7640c5 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1176,7 +1176,7 @@ _known_hosts_real()
COMPREPLY=( $( awk 'BEGIN {FS=","}
/^\s*[^|\#]/ {for (i=1; i<=2; ++i) { \
gsub(" .*$", "", $i); \
- if ($i ~ /'$awkcur'/) {print $i} \
+ if ($i ~ /'"$awkcur"'/) {print $i} \
}}' "${kh[@]}" 2>/dev/null ) )
fi
if [ ${#khd[@]} -gt 0 ]; then
diff --git a/test/fixtures/_known_hosts_real/known_hosts b/test/fixtures/_known_hosts_real/known_hosts
index d54a04d..bf39e84 100644
--- a/test/fixtures/_known_hosts_real/known_hosts
+++ b/test/fixtures/_known_hosts_real/known_hosts
@@ -2,3 +2,5 @@
|1|def
doo
ike ssh-rsa qwerty1234/Qwerty+1234==
+jub,10.0.0.1
+kyl,100.0.0.2
diff --git a/test/unit/_known_hosts_real.exp b/test/unit/_known_hosts_real.exp
index 4c95998..76ecf7f 100644
--- a/test/unit/_known_hosts_real.exp
+++ b/test/unit/_known_hosts_real.exp
@@ -14,19 +14,10 @@ setup
set test "Hosts should be put in COMPREPLY"
set hosts [get_hosts]
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
- # Hosts `doo' and `ike' are defined in ./fixtures/_known_hosts_real/known_hosts
-lappend hosts doo gee hus ike jar
-set hosts [lsort -ascii $hosts]
-set hosts [join $hosts "\\s+"]
- # Call _known_hosts
+ # doo, ike, jub, 10.0.0.1, kyl and 100.0.0.2 in ./fixtures/_known_hosts_real/known_hosts
+lappend hosts doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2
set cmd {_known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
-send "$cmd\r"
-expect -ex "$cmd\r\n"
-expect {
- -re "^$hosts\r\n/@$" { pass "$test" }
- -re /@ { unresolved "$test at prompt" }
- default { unresolved "$test" }
-}; # expect
+assert_bash_list $hosts $cmd $test
sync_after_int
@@ -35,23 +26,16 @@ sync_after_int
set test "Hosts should have username prefix and colon suffix"
set hosts [get_hosts]
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
- # Hosts `doo' and `ike' are defined in ./fixtures/_known_hosts_real/known_hosts
-lappend hosts doo gee hus ike jar
+ # doo, ike jub, 10.0.0.1, kyl and 100.0.0.2 in ./fixtures/_known_hosts_real/known_hosts
+lappend hosts doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2
set hosts [lsort -ascii $hosts]
set expected {}
foreach host $hosts {
lappend expected "user@$host:"
}; # foreach
-set expected [join $expected "\\s+"]
# Call _known_hosts
set cmd {_known_hosts_real -acF fixtures/_known_hosts_real/config 'user@'; echo_array COMPREPLY}
-send "$cmd\r"
-expect -ex "$cmd\r\n"
-expect {
- -re "^$expected\r\n/@$" { pass "$test" }
- -re /@ { unresolved "$test at prompt" }
- default { unresolved "$test" }
-}; # expect
+assert_bash_list $expected $cmd $test
sync_after_int
@@ -60,7 +44,6 @@ sync_after_int
set test "Config file containing space should work"
set hosts [get_hosts]
# Hosts `gee' and `hus' are defined in ./fixtures/_known_hosts_real/spaced conf
- # Hosts `doo' and `ike' are defined in ./fixtures/_known_hosts_real/known_hosts
# Host `two' is defined in ./fixtures/_known_hosts_real/known_hosts2
lappend hosts gee hus doo ike two
set hosts [lsort -ascii $hosts]
@@ -83,19 +66,11 @@ set test "Empty COMP_KNOWN_HOSTS_WITH_HOSTFILE should omit HOSTFILE"
assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE="
set hosts [get_hosts_avahi]
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
- # Hosts `doo' and `ike' are defined in ./fixtures/_known_hosts_real/known_hosts
-lappend hosts doo gee hus ike jar
-set hosts [lsort -ascii $hosts]
-set hosts [join $hosts "\\s+"]
+ # doo, ike, jub, 10.0.0.1, kyl and 100.0.0.2 in ./fixtures/_known_hosts_real/known_hosts
+lappend hosts doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2
# Call _known_hosts
set cmd {_known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
-send "$cmd\r"
-expect -ex "$cmd\r\n"
-expect {
- -re "^$hosts\r\n/@$" { pass "$test" }
- -re /@ { unresolved "$test at prompt" }
- default { unresolved "$test" }
-}; # expect
+assert_bash_list $hosts $cmd $test
sync_after_int
assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE"
--
bash-completion
More information about the Bash-completion-commits
mailing list