summaryrefslogtreecommitdiff
path: root/completions/crontab
diff options
context:
space:
mode:
Diffstat (limited to 'completions/crontab')
-rw-r--r--completions/crontab14
1 files changed, 7 insertions, 7 deletions
diff --git a/completions/crontab b/completions/crontab
index a5e5cc58..cac78533 100644
--- a/completions/crontab
+++ b/completions/crontab
@@ -12,13 +12,13 @@ _crontab()
;;
esac
- local -A opts=( [-u]= [-l]= [-r]= [-e]= )
+ local -A opts=([-u]="" [-l]="" [-r]="" [-e]="")
[[ $OSTYPE == *linux* ]] && opts[-i]=
[[ -d /sys/fs/selinux || -d /selinux ]] && opts[-s]=
local i
- for (( i=0; i < ${#words[@]}-1; i++ )); do
- [[ ${words[i]} ]] && unset "opts[${words[i]}]"
+ for i in "${!words[@]}"; do
+ [[ ${words[i]} && $i -ne $cword ]] && unset "opts[${words[i]}]"
case "${words[i]}" in
-l)
unset 'opts[-r]' 'opts[-e]' 'opts[-i]' 'opts[-s]'
@@ -35,14 +35,14 @@ _crontab()
esac
done
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '${!opts[@]}' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '${!opts[@]}' -- "$cur"))
return
fi
# do filenames only if we did not have -l, -r, or -e
- [[ "${words[*]}" == *\ -[lre]* ]] || _filedir
+ [[ ${words[*]} == *\ -[lre]* ]] || _filedir
} &&
-complete -F _crontab crontab
+ complete -F _crontab crontab
# ex: filetype=sh