Skip to content

Commit 55ed68d

Browse files
committed
getconf: New completion
1 parent cb7877c commit 55ed68d

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

completions/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ bashcomp_DATA = 2to3 \
114114
genaliases \
115115
gendiff \
116116
genisoimage \
117+
getconf \
117118
getent \
118119
gkrellm \
119120
gm \

completions/getconf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# getconf(1) completion -*- shell-script -*-
2+
3+
_getconf()
4+
{
5+
local cur prev words cword
6+
_init_completion || return
7+
8+
case $prev in
9+
-a)
10+
_filedir
11+
return
12+
;;
13+
-v)
14+
COMPREPLY=( $( compgen -W \
15+
'$( "$1" -a 2>/dev/null | awk "{ print \$1 }" )' -- \
16+
"${cur:-POSIX_V}" ) )
17+
return
18+
;;
19+
esac
20+
21+
if [[ $prev == PATH_MAX ]]; then # TODO more path vars, better handling
22+
_filedir
23+
elif [[ $cur == -* ]]; then
24+
COMPREPLY=( $( compgen -W '-a -v' -- "$cur" ) )
25+
else
26+
COMPREPLY=( $( compgen -W \
27+
'$( "$1" -a 2>/dev/null | awk "{ print \$1 }" )' -- "$cur" ) )
28+
fi
29+
} &&
30+
complete -F _getconf getconf

test/completion/getconf.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
assert_source_completions getconf

test/lib/completions/getconf.exp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
proc setup {} {
2+
save_env
3+
}
4+
5+
6+
proc teardown {} {
7+
assert_env_unmodified
8+
}
9+
10+
11+
setup
12+
13+
14+
assert_complete_any "getconf P"
15+
sync_after_int
16+
17+
assert_complete_any "getconf -"
18+
sync_after_int
19+
20+
assert_complete_any "getconf -a "
21+
sync_after_int
22+
23+
assert_complete_any "getconf -v "
24+
sync_after_int
25+
26+
assert_complete_any "getconf PATH_MAX "
27+
sync_after_int
28+
29+
30+
teardown

0 commit comments

Comments
 (0)