sudo: Handle options (Alioth: #311414).
This commit is contained in:
parent
08a2264c82
commit
91a61afe59
@ -1727,7 +1727,7 @@ _root_command()
|
|||||||
local root_command=$1
|
local root_command=$1
|
||||||
_command
|
_command
|
||||||
}
|
}
|
||||||
complete -F _root_command fakeroot gksu gksudo kdesudo really sudo
|
complete -F _root_command fakeroot gksu gksudo kdesudo really
|
||||||
|
|
||||||
# Return true if the completion should be treated as running as root
|
# Return true if the completion should be treated as running as root
|
||||||
_complete_as_root()
|
_complete_as_root()
|
||||||
|
@ -289,6 +289,7 @@ bashcomp_DATA = a2x \
|
|||||||
sshmitm \
|
sshmitm \
|
||||||
sshow \
|
sshow \
|
||||||
strace \
|
strace \
|
||||||
|
sudo \
|
||||||
svk \
|
svk \
|
||||||
sync_members \
|
sync_members \
|
||||||
sysbench \
|
sysbench \
|
||||||
|
48
completions/sudo
Normal file
48
completions/sudo
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# bash completion for sudo(8) -*- shell-script -*-
|
||||||
|
|
||||||
|
_sudo()
|
||||||
|
{
|
||||||
|
local cur prev words cword
|
||||||
|
_init_completion || return
|
||||||
|
|
||||||
|
local i mode=normal
|
||||||
|
for (( i=1; i <= COMP_CWORD; i++ )); do
|
||||||
|
if [[ ${COMP_WORDS[i]} != -* ]]; then
|
||||||
|
local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
|
||||||
|
local root_command=${COMP_WORDS[i]}
|
||||||
|
_command_offset $i
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
[[ ${COMP_WORDS[i]} == -@(u|U|g|C|p) ]] && ((i++))
|
||||||
|
if [[ ${COMP_WORDS[i]} == -e ]]; then
|
||||||
|
mode=edit
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
case "$prev" in
|
||||||
|
-u|-U)
|
||||||
|
COMPREPLY=( $( compgen -u -- "$cur" ) )
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
-g)
|
||||||
|
COMPREPLY=( $( compgen -g -- "$cur" ) )
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
-C|-p)
|
||||||
|
# argument required but no completions available
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '-A -b -C -E -e -g -H -h -i -K -k -L -l -ll
|
||||||
|
-n -P -p -S -s -U -u -V -v' -- "$cur" ) )
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [[ $mode == edit ]]; then
|
||||||
|
_filedir
|
||||||
|
fi
|
||||||
|
} && complete -F _sudo sudo
|
||||||
|
|
||||||
|
# ex: ts=4 sw=4 et filetype=sh
|
@ -32,6 +32,15 @@ assert_complete_dir "default/" "sudo mount /dev/sda1 def" $::srcdir/fixtures/sha
|
|||||||
sync_after_int
|
sync_after_int
|
||||||
|
|
||||||
|
|
||||||
|
set test "sudo -e should complete filenames and directories"
|
||||||
|
set dir $::srcdir/fixtures/shared/default
|
||||||
|
set files {foo foo.d/}
|
||||||
|
assert_complete_dir $files "sudo -e -u root bar foo" $dir $test
|
||||||
|
|
||||||
|
|
||||||
|
sync_after_int
|
||||||
|
|
||||||
|
|
||||||
# Find user/group suitable for testing.
|
# Find user/group suitable for testing.
|
||||||
set failed_find_unique_completion 0
|
set failed_find_unique_completion 0
|
||||||
foreach ug {user group} {
|
foreach ug {user group} {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user