File tree Expand file tree Collapse file tree 4 files changed +73
-0
lines changed Expand file tree Collapse file tree 4 files changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ cross_platform = 2to3 \
50
50
check_db \
51
51
check_perms \
52
52
checksec \
53
+ chflags \
53
54
_chfn \
54
55
chgrp \
55
56
chkconfig \
Original file line number Diff line number Diff line change
1
+ # chflags(1) completion -*- shell-script -*-
2
+
3
+ [[ $OSTYPE == * @ (bsd| darwin)* ]] || return 1
4
+
5
+ # References
6
+ #
7
+ # [1] FreeBSD - https://man.freebsd.org/cgi/man.cgi?chflags(1)
8
+ # [2] NetBSD - https://man.netbsd.org/NetBSD-9.0/chflags.1
9
+ # [3] OpenBSD - https://man.openbsd.org/chflags.1
10
+
11
+ _comp_cmd_chflags ()
12
+ {
13
+ local cur prev words cword comp_args
14
+ _comp_initialize -- " $@ " || return
15
+
16
+ if [[ $cur == -* ]]; then
17
+ # Complete -options
18
+ local w opts=" "
19
+ for w in " ${words[@]} " ; do
20
+ [[ $w == -R ]] && opts=" -H -L -P" && break
21
+ done
22
+ [[ $OSTYPE == * freebsd* ]] && opts=" $opts -x"
23
+ _comp_compgen -- -W ' -f -h -v -R $opts'
24
+ else
25
+ local REPLY
26
+ # The first argument is a list of flags; the rest are filedir.
27
+ _comp_count_args
28
+ if (( REPLY == 1 )) ; then
29
+ case " $OSTYPE " in
30
+ * netbsd* )
31
+ _comp_delimited , -W '
32
+ arch opaque nodump sappnd schg uappnd uchg'
33
+ ;;
34
+ * openbsd* )
35
+ _comp_delimited , -W ' arch nodump sappnd schg uappnd uchg'
36
+ ;;
37
+ * )
38
+ _comp_delimited , -W '
39
+ simmutable nosimmutable sappend nosappend archived
40
+ noarchived sunlink nosunlink opaque noopaque nodump
41
+ dump uimmutable nouimmutable uappend nouappend hidden
42
+ nohidden uunlink nouunlink'
43
+ ;;
44
+ esac
45
+ else
46
+ _comp_compgen_filedir
47
+ fi
48
+ fi
49
+ } &&
50
+ complete -F _comp_cmd_chflags chflags
51
+
52
+ # ex: filetype=sh
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ EXTRA_DIST = \
73
73
test_check_db.py \
74
74
test_check_perms.py \
75
75
test_checksec.py \
76
+ test_chflags.py \
76
77
test_chfn.py \
77
78
test_chgrp.py \
78
79
test_chkconfig.py \
Original file line number Diff line number Diff line change
1
+ import pytest
2
+
3
+
4
+ class TestChflags :
5
+ @pytest .mark .complete ("chflags no" )
6
+ def test_basic (self , completion ):
7
+ assert completion
8
+
9
+ @pytest .mark .complete ("chflags -" )
10
+ def test_options (self , completion ):
11
+ assert completion and "-P" not in completion
12
+
13
+ @pytest .mark .complete ("chflags -R -" )
14
+ def test_options_after_R (self , completion ):
15
+ assert "-P" in completion
16
+
17
+ @pytest .mark .complete ("chflags -v sappend " )
18
+ def test_first_word (self , completion ):
19
+ assert completion
You can’t perform that action at this time.
0 commit comments