@@ -17,6 +17,17 @@ class BashCompletionTest : CompletionTestBase("bash") {
1717 | fi
1818 |}
1919 |
20+ |__complete_files() {
21+ | # Generate filename completions
22+ | local word="${' $' } 1"
23+ | local IFS=${' $' } '\n'
24+ |
25+ | # quote each completion to support spaces and special characters
26+ | COMPREPLY=(${' $' } (compgen -o filenames -f -- "${' $' } word" | while read -r line; do
27+ | printf "%q\n" "${' $' } line"
28+ | done))
29+ |}
30+ |
2031 |__c_complete___o() {
2132 | COMPREPLY=(${' $' } (compgen -W "${' $' } (echo foo bar)" -- "${' $' } {COMP_WORDS[${' $' } COMP_CWORD]}"))
2233 |}
@@ -100,11 +111,22 @@ class BashCompletionTest : CompletionTestBase("bash") {
100111 | # this takes advantage of the fact that bash functions can write to local
101112 | # variables in their callers
102113 | (( i = i + 1 ))
103- | if [[ "${" $ " } {COMP_WORDS[${" $ " } i]}" == '=' ]]; then
114+ | if [[ "${' $ ' } {COMP_WORDS[${' $ ' } i]}" == '=' ]]; then
104115 | (( i = i + 1 ))
105116 | fi
106117 |}
107118 |
119+ |__complete_files() {
120+ | # Generate filename completions
121+ | local word="${' $' } 1"
122+ | local IFS=${' $' } '\n'
123+ |
124+ | # quote each completion to support spaces and special characters
125+ | COMPREPLY=(${' $' } (compgen -o filenames -f -- "${' $' } word" | while read -r line; do
126+ | printf "%q\n" "${' $' } line"
127+ | done))
128+ |}
129+ |
108130 |_c() {
109131 | local i=1
110132 | local in_param=''
@@ -381,6 +403,17 @@ class BashCompletionTest : CompletionTestBase("bash") {
381403 | fi
382404 |}
383405 |
406+ |__complete_files() {
407+ | # Generate filename completions
408+ | local word="${' $' } 1"
409+ | local IFS=${' $' } '\n'
410+ |
411+ | # quote each completion to support spaces and special characters
412+ | COMPREPLY=(${' $' } (compgen -o filenames -f -- "${' $' } word" | while read -r line; do
413+ | printf "%q\n" "${' $' } line"
414+ | done))
415+ |}
416+ |
384417 |_c() {
385418 | local i=1
386419 | local in_param=''
@@ -455,6 +488,17 @@ class BashCompletionTest : CompletionTestBase("bash") {
455488 | fi
456489 |}
457490 |
491+ |__complete_files() {
492+ | # Generate filename completions
493+ | local word="${' $' } 1"
494+ | local IFS=${' $' } '\n'
495+ |
496+ | # quote each completion to support spaces and special characters
497+ | COMPREPLY=(${' $' } (compgen -o filenames -f -- "${' $' } word" | while read -r line; do
498+ | printf "%q\n" "${' $' } line"
499+ | done))
500+ |}
501+ |
458502 |_c() {
459503 | local i=1
460504 | local in_param=''
@@ -525,7 +569,7 @@ class BashCompletionTest : CompletionTestBase("bash") {
525569 | "--none")
526570 | ;;
527571 | "--path")
528- | COMPREPLY=( ${ ' $ ' } (compgen -o default -- "${' $' } {word}"))
572+ | __complete_files "${' $' } {word}"
529573 | ;;
530574 | "--host")
531575 | COMPREPLY=(${' $' } (compgen -A hostname -- "${' $' } {word}"))
@@ -564,6 +608,17 @@ class BashCompletionTest : CompletionTestBase("bash") {
564608 | fi
565609 |}
566610 |
611+ |__complete_files() {
612+ | # Generate filename completions
613+ | local word="${' $' } 1"
614+ | local IFS=${' $' } '\n'
615+ |
616+ | # quote each completion to support spaces and special characters
617+ | COMPREPLY=(${' $' } (compgen -o filenames -f -- "${' $' } word" | while read -r line; do
618+ | printf "%q\n" "${' $' } line"
619+ | done))
620+ |}
621+ |
567622 |_c() {
568623 | local i=1
569624 | local in_param=''
0 commit comments