__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
|
||||
# Strip first character
|
||||
cur="${cur:1}"
|
||||
# Decrease cursor position
|
||||
((index--))
|
||||
# Decrease cursor position, staying >= 0
|
||||
[[ $index -gt 0 ]] && ((index--))
|
||||
done
|
||||
|
||||
# Does found word match cword?
|
||||
|
@ -450,8 +450,8 @@ _get_cword()
|
|||
]]; do
|
||||
# Strip first character
|
||||
cur="${cur:1}"
|
||||
# Decrease cursor position
|
||||
((index--))
|
||||
# Decrease cursor position, staying >= 0
|
||||
[[ $index -gt 0 ]] && ((index--))
|
||||
done
|
||||
|
||||
# Does found word matches cword?
|
||||
|
|
|
@ -249,4 +249,18 @@ expect {
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue