File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -1166,7 +1166,7 @@ _backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))'
1166
1166
#
1167
1167
_xinetd_services ()
1168
1168
{
1169
- local xinetddir=/etc/xinetd.d
1169
+ local xinetddir=${BASHCOMP_XINETDDIR :- / etc/ xinetd.d}
1170
1170
if [[ -d $xinetddir ]]; then
1171
1171
local IFS=$' \t\n ' reset=$( shopt -p nullglob) ; shopt -s nullglob
1172
1172
local -a svcs=( $( printf ' %s\n' $xinetddir /! ($_backup_glob )) )
Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ EXTRA_DIST = \
13
13
test_unit_parse_usage.py \
14
14
test_unit_quote.py \
15
15
test_unit_tilde.py \
16
- test_unit_variables.py
16
+ test_unit_variables.py \
17
+ test_unit_xinetd_services.py
17
18
18
19
all :
19
20
Original file line number Diff line number Diff line change
1
+ import pytest
2
+
3
+ from conftest import assert_bash_exec
4
+
5
+
6
+ @pytest .mark .bashcomp (cmd = None , ignore_env = r"^\+COMPREPLY=" )
7
+ class TestUnitXinetdServices :
8
+ def test_direct (self , bash ):
9
+ assert_bash_exec (bash , "_xinetd_services >/dev/null" )
10
+
11
+ def test_env_non_pollution (self , bash ):
12
+ """Test environment non-pollution, detected at teardown."""
13
+ assert_bash_exec (bash , "foo() { _xinetd_services; }; foo; unset foo" )
14
+
15
+ def test_basic (self , bash ):
16
+ output = assert_bash_exec (
17
+ bash ,
18
+ "foo() { local BASHCOMP_XINETDDIR=$PWD/shared/bin;unset COMPREPLY; "
19
+ '_xinetd_services; printf "%s\\ n" "${COMPREPLY[@]}"; }; foo; unset foo' ,
20
+ want_output = True ,
21
+ )
22
+ assert sorted (output .split ()) == ["arp" , "ifconfig" ]
You can’t perform that action at this time.
0 commit comments