| 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 | }
 | 
| 17 | complete -F _bad bad
 | 
| 18 | 
 | 
| 19 | _both() {
 | 
| 20 |   #echo '_both setting COMPREPLY and returning 124'
 | 
| 21 |   COMPREPLY=(x y)
 | 
| 22 |   return 124
 | 
| 23 | }
 | 
| 24 | complete -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 | }
 | 
| 32 | complete -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 | 
 | 
| 40 | complete -F _default -D
 |