Skip to content

Commit

Permalink
cryptsetup, nc, sh: Skip option args when counting arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed May 26, 2018
1 parent d2f55d0 commit 11dee0e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions completions/cryptsetup
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ _cryptsetup()
luksResume luksHeaderBackup luksHeaderRestore' -- "$cur" ) )
fi
else
local args
_count_args
local args; _count_args "" "-!(-*)[chslSbopitTdM]"
case $arg in
open|create|luksOpen|loopaesOpen|tcryptOpen)
case $args in
Expand Down
6 changes: 2 additions & 4 deletions completions/nc
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ _nc()
fi

# Complete 1st non-option arg only
local i
for (( i=1; i < cword; i++ )); do
[[ ${words[i]} != -* && ${words[i-1]} != -[IiOPpsTVwXx] ]] && return
done
local args; _count_args "" "-[IiOPpsTVwXx]"
[[ $args -eq 1 ]] || return

_known_hosts_real -- "$cur"
} &&
Expand Down
2 changes: 1 addition & 1 deletion completions/sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ _sh()
fi

local args ext=
_count_args
_count_args "" "@(-c|[-+]o)"
[[ $args -eq 1 ]] && ext=sh
_filedir $ext
} &&
Expand Down

0 comments on commit 11dee0e

Please sign in to comment.