Closes Alioth #311614 Globbing might occur if $cur contains one of these globbing characters: * ? [ ] The bug becomes apparent: On Cygwin if the glob-string contains backslashes as well, causing a warning (Cygwin >= 1.7): MS-DOS style path detected: ... Preferred POSIX equivalent is: ... CYGWIN environment variable option "nodosfilewarning" turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames On Linux, using strace, you can see bash-completion doing an unnecessary `open' system call. Steps to reproduce on Linux using `strace': Environment: Linux, bash-completion-1.0 1. Start bash with bash-completion loaded and find out PID ($$): $ echo $$ MYPID 2. In a second bash shell, `strace' the above PID: $ strace -e trace=open -f -o strace.log -p MYPID 3. Within the first bash shell, type: $ cur="?"; _kernel_versions 4. In the second bash shell, type ^C to quick `strace'. 5. Check `strace.log', here you can see bash accessing something it shouldn't: ... open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3 ... 6. The above call to `open' disappears if $cur in _kernel_versions gets quoted, and you repeat the steps above: _kernel_versions() { COMPREPLY=( $( compgen -W '$( command ls /lib/modules )' -- "$cur" ) ) }
284 lines
3.8 KiB
Bash
284 lines
3.8 KiB
Bash
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
|
|
# ex: ts=8 sw=8 noet filetype=sh
|
|
#
|
|
# dsniff util completion by Guillaume Rousse <rousse@ccr.jussieu.fr>
|
|
|
|
# arpspoof(8) completion
|
|
#
|
|
have arpspoof &&
|
|
_arpspoof()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-i)
|
|
_interfaces
|
|
return 0
|
|
;;
|
|
-t)
|
|
_known_hosts_real "$cur"
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-i -t' -- "$cur" ) )
|
|
else
|
|
_known_hosts_real "$cur"
|
|
fi
|
|
|
|
} &&
|
|
complete -F _arpspoof arpspoof
|
|
|
|
# dnsspoof(8) completion
|
|
#
|
|
have dnsspoof &&
|
|
_dnsspoof()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-i)
|
|
_interfaces
|
|
return 0
|
|
;;
|
|
-f)
|
|
_filedir
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-i -f' -- "$cur" ) )
|
|
fi
|
|
|
|
} &&
|
|
complete -F _dnsspoof dnsspoof
|
|
|
|
# dsniff(8) completion
|
|
#
|
|
have dsniff &&
|
|
_dsniff()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-@(r|w|f))
|
|
_filedir
|
|
return 0
|
|
;;
|
|
-i)
|
|
_interfaces
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-c -d -m -n -i -s -f -t \
|
|
-r -w' -- "$cur" ) )
|
|
fi
|
|
|
|
} &&
|
|
complete -F _dsniff dsniff
|
|
|
|
# filesnarf(8), mailsnarf(8) and msgsnarf (8) completion
|
|
#
|
|
have filesnarf || have mailsnarf || have msgsnarf &&
|
|
_snarf()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-i)
|
|
_interfaces
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-i -v' -- "$cur" ) )
|
|
fi
|
|
|
|
} &&
|
|
complete -F _snarf filesnarf mailsnarf msgsnarf
|
|
|
|
# macof(8) completion
|
|
#
|
|
have macof &&
|
|
_macof()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-i)
|
|
_interfaces
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-i -s -d -e -x -y -n' -- "$cur" ) )
|
|
fi
|
|
|
|
} &&
|
|
complete -F _macof macof
|
|
|
|
# sshmitm(8) completion
|
|
#
|
|
have sshmitm &&
|
|
_sshmitm()
|
|
{
|
|
local cur
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-d -I -p' -- "$cur" ) )
|
|
else
|
|
_known_hosts_real "$cur"
|
|
fi
|
|
|
|
} &&
|
|
complete -F _sshmitm sshmitm
|
|
|
|
# sshow(8) completion
|
|
#
|
|
have sshow &&
|
|
_sshow()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-i)
|
|
_interfaces
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-d -i' -- "$cur" ) )
|
|
fi
|
|
|
|
} &&
|
|
complete -F _sshow sshow
|
|
|
|
# tcpkill(8) completion
|
|
#
|
|
have tcpkill &&
|
|
_tcpkill()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-i)
|
|
_interfaces
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-i -1 -2 -3 -4 -5 -6 -7 -8 -9' -- "$cur" ) )
|
|
fi
|
|
|
|
} &&
|
|
complete -F _tcpkill tcpkill
|
|
|
|
# tcpnice(8) completion
|
|
#
|
|
have tcpnice &&
|
|
_tcpnice()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-i)
|
|
_interfaces
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-A -I -M -i' -- "$cur" ) )
|
|
fi
|
|
|
|
} &&
|
|
complete -F _tcpnice tcpnice
|
|
|
|
# urlsnarf(8) completion
|
|
#
|
|
have urlsnarf &&
|
|
_urlsnarf()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-i)
|
|
_interfaces
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-n -i -v' -- "$cur" ) )
|
|
fi
|
|
|
|
} &&
|
|
complete -F _urlsnarf urlsnarf
|
|
|
|
# webmitm(8) completion
|
|
#
|
|
have webmitm &&
|
|
_webmitm()
|
|
{
|
|
local cur
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-d' -- "$cur" ) )
|
|
else
|
|
_known_hosts_real "$cur"
|
|
fi
|
|
|
|
} &&
|
|
complete -F _webmitm webmitm
|