Merge pull request #64 from Mellbourn/fix-negative-comp-words

Including tweaks to conditional statements

I think the original conditionals would always be false. That prevents
using completions which rely on identifying the penultimate and
antepenultimate portions of typed commandline.
This commit is contained in:
Tim Byrne 2017-05-08 16:30:30 -05:00
commit 9d21376f88
No known key found for this signature in database
GPG Key ID: 14DB4FC2465A4B12
1 changed files with 8 additions and 2 deletions

View File

@ -9,8 +9,14 @@ if declare -F _git > /dev/null; then
_yadm() {
local current=${COMP_WORDS[COMP_CWORD]}
local penultimate=${COMP_WORDS[COMP_CWORD-1]}
local antepenultimate=${COMP_WORDS[COMP_CWORD-2]}
local penultimate
if [ "$((COMP_CWORD-1))" -ge "0" ]; then
penultimate=${COMP_WORDS[COMP_CWORD-1]}
fi
local antepenultimate
if [ "$((COMP_CWORD-2))" -ge "0" ]; then
antepenultimate=${COMP_WORDS[COMP_CWORD-2]}
fi
local GIT_DIR
# shellcheck disable=SC2034