OILS / testdata / completion / return-124.bash View on Github | oilshell.org

40 lines, 21 significant
1_bad() {
2 #argv "$@"
3
4 echo '_bad returning 124'
5
6 # This caused an infinite loop in OSH, but not in bash. We have to test if
7 # the return value is 124 AND the compspec was updated.
8 #
9 # In bash, it seems like you EITHER set COMPREPLY or return 124, not BOTH!
10 # If it sees 124, it doesn't process the completions (unlike OSH at the
11 # moment).
12
13 #COMPREPLY=(x y)
14
15 return 124
16}
17complete -F _bad bad
18
19_both() {
20 #echo '_both setting COMPREPLY and returning 124'
21 COMPREPLY=(x y)
22 return 124
23}
24complete -F _both both
25
26_both2() {
27 #echo '_both setting COMPREPLY and returning 124'
28 COMPREPLY=(x y)
29 complete -W 'b1 b2' both2
30 return 124
31}
32complete -F _both2 both2
33
34_default() {
35 echo '_default returning 124 without changing completion spec'
36 # We're supposed to source something here, but we didn't
37 return 124
38}
39
40complete -F _default -D