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" ) ) }
273 lines
4.1 KiB
Bash
273 lines
4.1 KiB
Bash
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
|
|
# ex: ts=8 sw=8 noet filetype=sh
|
|
#
|
|
# bash completion for openldap
|
|
|
|
have ldapsearch && {
|
|
_ldap_uris()
|
|
{
|
|
COMPREPLY=( $( compgen -W 'ldap:// ldaps://' -- "$cur" ) )
|
|
}
|
|
|
|
_ldap_protocols()
|
|
{
|
|
COMPREPLY=( $( compgen -W '2 3' -- "$cur" ) )
|
|
}
|
|
|
|
_ldapsearch()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-h)
|
|
_known_hosts_real "$cur"
|
|
return 0
|
|
;;
|
|
-H)
|
|
_ldap_uris
|
|
return 0
|
|
;;
|
|
-T)
|
|
_filedir -d
|
|
return 0
|
|
;;
|
|
-@(f|y))
|
|
_filedir
|
|
return 0
|
|
;;
|
|
-s)
|
|
COMPREPLY=( $( compgen -W 'base one sub children' \
|
|
-- "$cur" ) )
|
|
return 0
|
|
;;
|
|
-a)
|
|
COMPREPLY=( $( compgen -W 'never always search find' \
|
|
-- "$cur" ) )
|
|
return 0
|
|
;;
|
|
-P)
|
|
_ldap_protocols
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-n -u -v -t -tt -T -F -A -C -L -LL \
|
|
-LLL -M -MM -S -d -f -x -D -W -w -y -H -h -p -b -s -a \
|
|
-P -e -E -l -z -O -I -Q -U -R -X -Y -Z -ZZ' -- "$cur" ) )
|
|
fi
|
|
}
|
|
complete -F _ldapsearch ldapsearch
|
|
|
|
_ldapaddmodify()
|
|
{
|
|
local cur prev options
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-h)
|
|
_known_hosts_real "$cur"
|
|
return 0
|
|
;;
|
|
-H)
|
|
_ldap_uris
|
|
return 0
|
|
;;
|
|
-@(S|f|y))
|
|
_filedir
|
|
return 0
|
|
;;
|
|
-P)
|
|
_ldap_protocols
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
options='-c -S -n -v -M -MM -d -D -W -w -y -h -H -p -P -O -I \
|
|
-Q -U -R -x -X -Y -Z -ZZ -f'
|
|
if [[ ${COMP_WORDS[0]} == ldapmodify ]]; then
|
|
options="$options -a"
|
|
fi
|
|
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
|
fi
|
|
}
|
|
complete -F _ldapaddmodify ldapadd ldapmodify
|
|
|
|
_ldapdelete()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-h)
|
|
_known_hosts_real "$cur"
|
|
return 0
|
|
;;
|
|
-H)
|
|
_ldap_uris
|
|
return 0
|
|
;;
|
|
-@(f|y))
|
|
_filedir
|
|
return 0
|
|
;;
|
|
-P)
|
|
_ldap_protocols
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-n -v -c -M -MM -d -f -D -W -w -y \
|
|
-H -h -P -p -O -U -R -r -x -I -Q -X -Y -Z -ZZ' \
|
|
-- "$cur" ) )
|
|
fi
|
|
}
|
|
complete -F _ldapdelete ldapdelete
|
|
|
|
_ldapcompare()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-h)
|
|
_known_hosts_real "$cur"
|
|
return 0
|
|
;;
|
|
-H)
|
|
_ldap_uris
|
|
return 0
|
|
;;
|
|
-y)
|
|
_filedir
|
|
return 0
|
|
;;
|
|
-P)
|
|
_ldap_protocols
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-n -v -z -M -MM -d -D -W -w -y \
|
|
-H -h -P -p -O -I -Q -U -R -x -X -Y -Z -ZZ' \
|
|
-- "$cur" ) )
|
|
fi
|
|
}
|
|
complete -F _ldapcompare ldapcompare
|
|
|
|
_ldapmodrdn()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-h)
|
|
_known_hosts_real "$cur"
|
|
return 0
|
|
;;
|
|
-H)
|
|
_ldap_uris
|
|
return 0
|
|
;;
|
|
-@(f|y))
|
|
_filedir
|
|
return 0
|
|
;;
|
|
-P)
|
|
_ldap_protocols
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-r -s -n -v -c -M -MM -d -D -W -w \
|
|
-y -H -h -P -p -O -I -Q -U -R -x -X -Y -Z -ZZ -f' \
|
|
-- "$cur" ) )
|
|
fi
|
|
}
|
|
complete -F _ldapmodrdn ldapmodrdn
|
|
|
|
_ldapwhoami()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-h)
|
|
_known_hosts_real "$cur"
|
|
return 0
|
|
;;
|
|
-H)
|
|
_ldap_uris
|
|
return 0
|
|
;;
|
|
-@(f|y))
|
|
_filedir
|
|
return 0
|
|
;;
|
|
-P)
|
|
_ldap_protocols
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-n -v -z -d -D -W -w -y -H -h -p -P \
|
|
-O -I -Q -U -R -x -X -Y -Z -ZZ' -- "$cur" ) )
|
|
fi
|
|
}
|
|
complete -F _ldapwhoami ldapwhoami
|
|
|
|
_ldappasswd()
|
|
{
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
cur=`_get_cword`
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
case "$prev" in
|
|
-h)
|
|
_known_hosts_real "$cur"
|
|
return 0
|
|
;;
|
|
-H)
|
|
_ldap_uris
|
|
return 0
|
|
;;
|
|
-@(t|T|y))
|
|
_filedir
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-A -a -t -d -D -H -h -n -p -S -s -T \
|
|
-v -W -w -y -O -I -Q -U -R -x -X -Y -Z -ZZ' -- "$cur" ) )
|
|
fi
|
|
}
|
|
complete -F _ldappasswd ldappasswd
|
|
}
|