cli: fix bash completion for curser not at EOL

If the curser is not at the end of the line, we want to complete
by ignoring everything right of the curser. However, the variable
$cur is set to the spaces since the last word, so we have to
get rid of them first

Without this, the following did not complete:
  $ nmcli connection modify id   <TAB>  lo
because $cur is set to '  '.

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2013-11-13 14:38:13 +01:00
parent ce370fab64
commit 93f5687d7b

View file

@ -544,6 +544,13 @@ _nmcli()
words[i]="$(echo "${words[i]}" | xargs 2>/dev/null || true)"
done
# In case the cursor is not at the end of the line,
# $cur consists of spaces that we want do remove.
# For example: `nmcli connection modify id <TAB> lo`
if [[ "$cur" =~ [[:space:]]+ ]]; then
cur=''
fi
_nmcli_complete_OPTIONS && return 0
local command="${words[1]}"