summaryrefslogtreecommitdiffstats
path: root/completions/chgrp
blob: 1e19750c2d40c369af6b8b6126968bdcc4bec5e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# chgrp(1) completion                                      -*- shell-script -*-

_comp_cmd_chgrp()
{
    local cur prev words cword was_split comp_args
    _comp_initialize -s -- "$@" || return

    cur=${cur//\\\\/}

    if [[ $prev == --reference ]]; then
        _comp_compgen_filedir
        return
    fi

    [[ $was_split ]] && return

    # options completion
    if [[ $cur == -* ]]; then
        local w opts=""
        for w in "${words[@]}"; do
            [[ $w == -@(R|-recursive) ]] && opts="-H -L -P" && break
        done
        _comp_compgen -- -W '-c -h -f -R -v --changes --dereference
            --no-dereference --silent --quiet --reference --recursive --verbose
            --help --version $opts'
        return
    fi

    # first parameter on line or first since an option?
    if [[ $cword -eq 1 && $cur != -* || $prev == -* ]]; then
        _comp_compgen_allowed_groups
    else
        _comp_compgen_filedir
    fi

} &&
    complete -F _comp_cmd_chgrp chgrp

# ex: filetype=sh