2010-06-18 00:24:04 +03:00
|
|
|
# crontab(1) completion
|
|
|
|
|
2011-04-05 00:35:51 +03:00
|
|
|
have crontab || return
|
|
|
|
|
2010-06-18 00:24:04 +03:00
|
|
|
_crontab()
|
|
|
|
{
|
2011-04-20 14:42:30 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2010-06-18 00:24:04 +03:00
|
|
|
|
|
|
|
case $prev in
|
|
|
|
-u)
|
2010-10-31 21:23:26 +02:00
|
|
|
_allowed_users
|
2010-06-18 00:24:04 +03:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2011-04-27 17:19:29 +03:00
|
|
|
local -A opts=( [-u]= [-l]= [-r]= [-e]= )
|
|
|
|
[[ $OSTYPE == *linux* ]] && opts[-i]=
|
2011-05-29 19:02:13 +03:00
|
|
|
[[ -d /sys/fs/selinux || -d /selinux ]] && opts[-s]=
|
2011-04-27 17:19:29 +03:00
|
|
|
|
|
|
|
local i
|
2011-04-20 14:42:30 +03:00
|
|
|
for (( i=0; i < ${#words[@]}-1; i++ )); do
|
2011-04-27 17:19:29 +03:00
|
|
|
[[ ${words[i]} ]] && unset opts[${words[i]}]
|
2011-04-20 14:42:30 +03:00
|
|
|
case "${words[i]}" in
|
2010-06-18 00:24:04 +03:00
|
|
|
-l)
|
2011-04-27 17:19:29 +03:00
|
|
|
unset opts[-r] opts[-e] opts[-i] opts[-s]
|
2010-06-18 00:24:04 +03:00
|
|
|
;;
|
|
|
|
-e)
|
2011-04-27 17:19:29 +03:00
|
|
|
unset opts[-l] opts[-r] opts[-i]
|
2010-06-18 00:24:04 +03:00
|
|
|
;;
|
|
|
|
-r)
|
2011-04-27 17:19:29 +03:00
|
|
|
unset opts[-l] opts[-e]
|
2010-06-18 00:24:04 +03:00
|
|
|
;;
|
|
|
|
-u)
|
2011-04-27 17:19:29 +03:00
|
|
|
unset opts[-i]
|
2010-06-18 00:24:04 +03:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ "$cur" == -* ]]; then
|
2011-04-27 17:19:29 +03:00
|
|
|
COMPREPLY=( $( compgen -W '${!opts[@]}' -- "$cur" ) )
|
2010-06-18 00:24:04 +03:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# do filenames only if we did not have -l, -r, or -e
|
2011-04-20 14:42:30 +03:00
|
|
|
[[ "${words[@]}" == *\ -@(l|r|e)* ]] || _filedir
|
2010-06-18 00:24:04 +03:00
|
|
|
} &&
|
2010-11-01 19:26:53 +02:00
|
|
|
complete -F _crontab crontab
|
2010-06-18 00:24:04 +03:00
|
|
|
|
|
|
|
# Local variables:
|
|
|
|
# mode: shell-script
|
|
|
|
# sh-basic-offset: 4
|
|
|
|
# sh-indent-comment: t
|
|
|
|
# indent-tabs-mode: nil
|
|
|
|
# End:
|
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|