More known hosts IPv6 completion fixes, thanks to Yoshinori KUNIGA.

https://bugzilla.redhat.com/show_bug.cgi?id=630658#c4
This commit is contained in:
Ville Skyttä 2010-10-04 21:29:44 +03:00
parent 3d8efed618
commit 1da64f602a
4 changed files with 18 additions and 16 deletions

View File

@ -22,8 +22,7 @@ bash-completion (2.x)
* Drop bad kompare filename completion (Alioth: #312708). * Drop bad kompare filename completion (Alioth: #312708).
* Make _filedir and _filedir_xspec complete uppercase versions of their * Make _filedir and _filedir_xspec complete uppercase versions of their
filename extension arguments in addition to exact case matches. filename extension arguments in addition to exact case matches.
* Fix known hosts completion for IPv6 addresses whose last 16 bits are digits * IPv6 known hosts completion fixes (Alioth: #312695, RedHat: #630658).
(Alioth: #312695, RedHat: #630658).
* Improve mplayer and mencoder completions. * Improve mplayer and mencoder completions.
* Fixes to completions for filenames containing tabs (RedHat: #629518). * Fixes to completions for filenames containing tabs (RedHat: #629518).

View File

@ -1279,16 +1279,16 @@ _known_hosts_real()
awkcur=${awkcur//\./\\\.} awkcur=${awkcur//\./\\\.}
curd=$awkcur curd=$awkcur
if [[ "$awkcur" == [0-9]*.* ]]; then if [[ "$awkcur" == [0-9]*[.:]* ]]; then
# Digits followed by a dot - just search for that # Digits followed by a dot or a colon - just search for that
awkcur="^$awkcur.*" awkcur="^$awkcur[.:]*"
elif [[ "$awkcur" == [0-9]* ]]; then elif [[ "$awkcur" == [0-9]* ]]; then
# Digits followed by no dot - search for digits followed # Digits followed by no dot or colon - search for digits followed
# by a dot # by a dot or a colon
awkcur="^$awkcur.*\." awkcur="^$awkcur.*[.:]"
elif [ -z "$awkcur" ]; then elif [ -z "$awkcur" ]; then
# A blank - search for a dot or an alpha character # A blank - search for a dot, a colon, or an alpha character
awkcur="[a-z.]" awkcur="[a-z.:]"
else else
awkcur="^$awkcur" awkcur="^$awkcur"
fi fi

View File

@ -8,3 +8,6 @@ kyl,100.0.0.2
[blah]:1234 [blah]:1234
fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555
fe80::123:0xff:dead:beef%eth0 fe80::123:0xff:dead:beef%eth0
1111:2222:3333:4444:5555:6666:xxxx:abab
11xx:2222:3333:4444:5555:6666:xxxx:abab
::42

View File

@ -17,8 +17,8 @@ setup
set test "Hosts should be put in COMPREPLY" set test "Hosts should be put in COMPREPLY"
set hosts [get_hosts] set hosts [get_hosts]
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 and fe80::123:0xff:dead:beef%eth0 in ./fixtures/_known_hosts_real/known_hosts # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts
lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY} set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
assert_bash_list $hosts $cmd $test assert_bash_list $hosts $cmd $test
@ -29,8 +29,8 @@ sync_after_int
set test "Hosts should have username prefix and colon suffix" set test "Hosts should have username prefix and colon suffix"
set hosts [get_hosts] set hosts [get_hosts]
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 and fe80::123:0xff:dead:beef%eth0 in ./fixtures/_known_hosts_real/known_hosts # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts
lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
set hosts [lsort -ascii $hosts] set hosts [lsort -ascii $hosts]
set expected {} set expected {}
foreach host $hosts { foreach host $hosts {
@ -103,8 +103,8 @@ set test "Empty COMP_KNOWN_HOSTS_WITH_HOSTFILE should omit HOSTFILE"
assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE=" assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE="
set hosts [get_hosts_avahi] set hosts [get_hosts_avahi]
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 and fe80::123:0xff:dead:beef%eth0 in ./fixtures/_known_hosts_real/known_hosts # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts
lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
# Call _known_hosts # Call _known_hosts
set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY} set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
assert_bash_list $hosts $cmd $test assert_bash_list $hosts $cmd $test