Skip to content

Commit af3792b

Browse files
committed
tests: Ensure we split options into array
1 parent dbd3e3d commit af3792b

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

bash-completions-getter.sh

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ parse_complete_options() {
115115
COMPLETE_CALL_TYPE=${1#-}
116116
shift 2
117117
;;
118-
-pr|-D|-E|-A|-G|-F|-C|-P|-S)
118+
-A)
119+
COMPLETE_ACTIONS+=("${2}")
120+
shift 2
121+
;;
122+
-pr|-D|-E|-G|-F|-C|-P|-S)
119123
shift 2
120124
;;
121125
-o)
@@ -131,6 +135,54 @@ parse_complete_options() {
131135
# TODO, but to support this we also need to handle compopt and -o
132136
shift 2
133137
;;
138+
-a)
139+
COMPLETE_ACTIONS+=("alias")
140+
shift
141+
;;
142+
-b)
143+
COMPLETE_ACTIONS+=("builtin")
144+
shift
145+
;;
146+
-c)
147+
COMPLETE_ACTIONS+=("command")
148+
shift
149+
;;
150+
-d)
151+
COMPLETE_ACTIONS+=("directory")
152+
shift
153+
;;
154+
-e)
155+
COMPLETE_ACTIONS+=("export")
156+
shift
157+
;;
158+
-f)
159+
COMPLETE_ACTIONS+=("file")
160+
shift
161+
;;
162+
-g)
163+
COMPLETE_ACTIONS+=("group")
164+
shift
165+
;;
166+
-j)
167+
COMPLETE_ACTIONS+=("job")
168+
shift
169+
;;
170+
-k)
171+
COMPLETE_ACTIONS+=("keyword")
172+
shift
173+
;;
174+
-s)
175+
COMPLETE_ACTIONS+=("service")
176+
shift
177+
;;
178+
-u)
179+
COMPLETE_ACTIONS+=("user")
180+
shift
181+
;;
182+
-v)
183+
COMPLETE_ACTIONS+=("variable")
184+
shift
185+
;;
134186
-*)
135187
shift
136188
;;

tests/test-bash-completions-getter.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ if [ -n "$DEBUG" ]; then
2020
fi
2121

2222
check_completion() {
23-
local OIFS=$IFS
2423
local input="$1"
2524
local expected_completions=("$2")
2625
local expected_options=("$3")
2726
local expected_exit_code=${4:-0};
2827
local -a output
28+
local -a options
2929

3030
echo "Checking completion $input" >&2
3131

@@ -53,9 +53,7 @@ check_completion() {
5353
return 0
5454
fi
5555

56-
IFS=' '
57-
local options=("${output[0]}")
58-
IFS=$OIFS
56+
read -r -a options <<< "${output[0]}"
5957
local completions=("${output[@]:1}")
6058

6159
echo -n " options: " >&2; printf "'%s'," "${options[@]}" >&2; echo >&2

0 commit comments

Comments
 (0)