__get_cword: avoid $index < 0 (Alioth: #315107)
Modified-by: Ville Skyttä <ville.skytta@iki.fi> Signed-off-by: Ondrej Oprala <ooprala@redhat.com>master
parent
f68589fde4
commit
fa1ad7dff9
|
@ -320,8 +320,8 @@ __get_cword_at_cursor_by_ref()
|
||||||
]]; do
|
]]; do
|
||||||
# Strip first character
|
# Strip first character
|
||||||
cur="${cur:1}"
|
cur="${cur:1}"
|
||||||
# Decrease cursor position
|
# Decrease cursor position, staying >= 0
|
||||||
((index--))
|
[[ $index -gt 0 ]] && ((index--))
|
||||||
done
|
done
|
||||||
|
|
||||||
# Does found word match cword?
|
# Does found word match cword?
|
||||||
|
@ -450,8 +450,8 @@ _get_cword()
|
||||||
]]; do
|
]]; do
|
||||||
# Strip first character
|
# Strip first character
|
||||||
cur="${cur:1}"
|
cur="${cur:1}"
|
||||||
# Decrease cursor position
|
# Decrease cursor position, staying >= 0
|
||||||
((index--))
|
[[ $index -gt 0 ]] && ((index--))
|
||||||
done
|
done
|
||||||
|
|
||||||
# Does found word matches cword?
|
# Does found word matches cword?
|
||||||
|
|
|
@ -249,4 +249,18 @@ expect {
|
||||||
sync_after_int
|
sync_after_int
|
||||||
|
|
||||||
|
|
||||||
|
set test "index shouldn't drop below 0"
|
||||||
|
set dir $::srcdir/fixtures/_get_cword
|
||||||
|
set cmd "scp"
|
||||||
|
send "$cmd ääää§ se\t\r\n"
|
||||||
|
expect {
|
||||||
|
-re "index: substring expression < 0" { fail "$test" }
|
||||||
|
-re /@ { pass "$test" }
|
||||||
|
default { unresolved "$test" }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sync_after_int
|
||||||
|
|
||||||
|
|
||||||
teardown
|
teardown
|
||||||
|
|
Loading…
Reference in New Issue