Skip to content

Commit

Permalink
*: Protect _known_hosts_real from user input treated as options
Browse files Browse the repository at this point in the history
Avoids e.g. errors like

$ xgamma -display --<TAB>
error: _known_hosts_real: missing mandatory argument CWORD
  • Loading branch information
scop committed Jul 9, 2017
1 parent 3708590 commit 8706bc1
Show file tree
Hide file tree
Showing 46 changed files with 75 additions and 75 deletions.
2 changes: 1 addition & 1 deletion completions/arping
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ _arping()
return
fi

_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
} &&
complete -F _arping arping

Expand Down
4 changes: 2 additions & 2 deletions completions/arpspoof
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ _arpspoof()
return
;;
-t)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
esac

if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
else
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
fi

} &&
Expand Down
6 changes: 3 additions & 3 deletions completions/chronyc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ _chronyc_command_args()
local -a args=( $( compgen -W "$( $1 help 2>/dev/null | \
awk '/^'$prev'\s[^ []/ { gsub("\\|", " ", $2); print $2 }' )" ) )
case $args in
\<address\>) _known_hosts_real "$cur" ;;
\<address\>) _known_hosts_real -- "$cur" ;;
\<*) ;;
*) COMPREPLY+=( $( compgen -W '${args[@]}' -- "$cur" ) ) ;;
esac
Expand All @@ -21,7 +21,7 @@ _chronyc()
return
;;
-h)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
esac
Expand Down Expand Up @@ -50,7 +50,7 @@ _chronyc()
fi
;;
2)
[[ $prev == @(peer|server) ]] && _known_hosts_real "$cur"
[[ $prev == @(peer|server) ]] && _known_hosts_real -- "$cur"
;;
esac
} &&
Expand Down
2 changes: 1 addition & 1 deletion completions/curl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ _curl()
return
;;
-x|--proxy|--socks4|--socks4a|--socks5|--socks5-hostname)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
--pubkey)
Expand Down
2 changes: 1 addition & 1 deletion completions/dhclient
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _dhclient()
return
;;
-s)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion completions/freeciv-gtk2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ _civclient()
return
;;
-s|--server)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion completions/gkrellm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ _gkrellm()
return
;;
-s|--server)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-l|--logfile)
Expand Down
4 changes: 2 additions & 2 deletions completions/hping2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _hping2()
return
;;
-a|--spoof)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-o|--tos)
Expand All @@ -27,7 +27,7 @@ _hping2()
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
else
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
fi
} &&
complete -F _hping2 hping hping2 hping3
Expand Down
2 changes: 1 addition & 1 deletion completions/iperf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ _iperf()
return
;;
-c|--client)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-x|--reportexclude)
Expand Down
2 changes: 1 addition & 1 deletion completions/ipmitool
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ _ipmitool()
return
;;
-H)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-f|-S|-O)
Expand Down
2 changes: 1 addition & 1 deletion completions/jps
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _jps()
COMPREPLY=( $( compgen -W "-q -m -l -v -V -J -help" -- "$cur" ) )
[[ $COMPREPLY == -J* ]] && compopt -o nospace
else
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
fi
} &&
complete -F _jps jps
Expand Down
2 changes: 1 addition & 1 deletion completions/ktutil
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ _ktutil()
return
;;
-a|--admin-server)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-r|--realm)
Expand Down
14 changes: 7 additions & 7 deletions completions/ldapsearch
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _ldapsearch()

case $prev in
-h)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-H)
Expand Down Expand Up @@ -60,7 +60,7 @@ _ldapaddmodify()

case $prev in
-h)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-H)
Expand Down Expand Up @@ -90,7 +90,7 @@ _ldapdelete()

case $prev in
-h)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-H)
Expand Down Expand Up @@ -120,7 +120,7 @@ _ldapcompare()

case $prev in
-h)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-H)
Expand Down Expand Up @@ -150,7 +150,7 @@ _ldapmodrdn()

case $prev in
-h)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-H)
Expand Down Expand Up @@ -180,7 +180,7 @@ _ldapwhoami()

case $prev in
-h)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-H)
Expand Down Expand Up @@ -210,7 +210,7 @@ _ldappasswd()

case $prev in
-h)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-H)
Expand Down
2 changes: 1 addition & 1 deletion completions/ldapvi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ _ldapvi()

case $prev in
-h|--host)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-Y|--sasl-mech)
Expand Down
2 changes: 1 addition & 1 deletion completions/lftp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ _lftp()

COMPREPLY=( $( compgen -W \
'$( cut -f 1 -s ~/.lftp/bookmarks ${XDG_DATA_HOME:-$HOME/.local/share}/lftp/bookmarks 2>/dev/null )' -- "$cur" ) )
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
} &&
complete -F _lftp lftp

Expand Down
2 changes: 1 addition & 1 deletion completions/medusa
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ _medusa()

case $prev in
-h)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-H|-U|-P|-C|-O)
Expand Down
2 changes: 1 addition & 1 deletion completions/munin-node-configure
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ _munin_node_configure()
return
;;
--snmp)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
--snmpversion)
Expand Down
2 changes: 1 addition & 1 deletion completions/munin-update
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _munin_update()
return
;;
--host)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion completions/mussh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _mussh()
return
;;
-p|-h)
[[ $cur == *@* ]] && _user_at_host || _known_hosts_real -a "$cur"
[[ $cur == *@* ]] && _user_at_host || _known_hosts_real -a -- "$cur"
return
;;
-c)
Expand Down
2 changes: 1 addition & 1 deletion completions/mysql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _mysql()
;;

-h|--host)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
--default-character-set)
Expand Down
2 changes: 1 addition & 1 deletion completions/mysqladmin
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _mysqladmin()
return
;;
-h|--host)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
--character-sets-dir|--ssl-capath)
Expand Down
4 changes: 2 additions & 2 deletions completions/nc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ _nc()
return
;;
-x)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
esac
Expand All @@ -39,7 +39,7 @@ _nc()
[[ ${words[i]} != -* && ${words[i-1]} != -[IiOPpsTVwXx] ]] && return
done

_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
} &&
complete -F _nc nc

Expand Down
4 changes: 2 additions & 2 deletions completions/nmap
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _nmap()
return
;;
-b|--dns-servers)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
esac
Expand All @@ -42,7 +42,7 @@ _nmap()
-A --datadir --send-eth --send-ip --privilege--unprivileged -V
-h' -- "$cur" ) )
else
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
fi
} &&
complete -F _nmap nmap
Expand Down
4 changes: 2 additions & 2 deletions completions/nslookup
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ _nslookup()
local args
_count_args =
if [[ $args -le 2 ]]; then
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
[[ $args -eq 1 && $cur == @(|-) ]] && COMPREPLY+=( - )
fi
} &&
Expand Down Expand Up @@ -79,7 +79,7 @@ _host()
return
fi

_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
} &&
complete -F _host host

Expand Down
2 changes: 1 addition & 1 deletion completions/ntpdate
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ _ntpdate()
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
else
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
fi
} &&
complete -F _ntpdate ntpdate
Expand Down
2 changes: 1 addition & 1 deletion completions/openssl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ _openssl()
return
;;
-connect)
_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
return
;;
-starttls)
Expand Down
2 changes: 1 addition & 1 deletion completions/ping
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ _ping()
return
fi

_known_hosts_real "$cur"
_known_hosts_real -- "$cur"
} &&
complete -F _ping ping ping6

Expand Down
Loading

0 comments on commit 8706bc1

Please sign in to comment.