Skip to content

Commit 022a061

Browse files
authored
Merge pull request #27 from DannyBen/fix/spaced-filenames
Fix file/folder completion when they contain spaces
2 parents 42cc38c + 2f2c63b commit 022a061

File tree

17 files changed

+51
-37
lines changed

17 files changed

+51
-37
lines changed

lib/completely/templates/template.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
% patterns.each do |pattern|
2020
% next if pattern.empty?
2121
<%= pattern.case_string %>)
22-
COMPREPLY=($(compgen <%= pattern.compgen %> -- "$cur"))
22+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen <%= pattern.compgen %> -- "$cur" )
2323
;;
2424

2525
% end

lib/completely/templates/tester-template.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ COMP_POINT=${#COMP_LINE}
1616
COMP_CWORD=<%= cword %>
1717

1818
<%= function_name %>
19-
echo "${COMPREPLY[*]}"
19+
for suggestion in "${COMPREPLY[@]}"; do
20+
echo "$suggestion"
21+
done
22+

lib/completely/tester.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test(compline)
1414
f << tester_script(compline)
1515
f.flush
1616
`bash #{f.path}`
17-
end.split " "
17+
end.split "\n"
1818
end
1919

2020
def tester_script(compline)

spec/approvals/cli/generated-script

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ _mygit_completions() {
1010

1111
case "$compline" in
1212
'status'*)
13-
COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur"))
13+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur" )
1414
;;
1515

1616
'commit'*)
17-
COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur"))
17+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur" )
1818
;;
1919

2020
'init'*)
21-
COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur"))
21+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--bare" -- "$cur" )
2222
;;
2323

2424
*)
25-
COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur"))
25+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version status init commit" -- "$cur" )
2626
;;
2727

2828
esac

spec/approvals/cli/generated-script-alt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ _mycomps() {
1010

1111
case "$compline" in
1212
'status'*)
13-
COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur"))
13+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur" )
1414
;;
1515

1616
'commit'*)
17-
COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur"))
17+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur" )
1818
;;
1919

2020
'init'*)
21-
COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur"))
21+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--bare" -- "$cur" )
2222
;;
2323

2424
*)
25-
COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur"))
25+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version status init commit" -- "$cur" )
2626
;;
2727

2828
esac

spec/approvals/cli/generated-wrapped-script

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ give_comps() {
1111
echo $''
1212
echo $' case "$compline" in'
1313
echo $' \'status\'*)'
14-
echo $' COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur"))'
14+
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur" )'
1515
echo $' ;;'
1616
echo $''
1717
echo $' \'commit\'*)'
18-
echo $' COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur"))'
18+
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur" )'
1919
echo $' ;;'
2020
echo $''
2121
echo $' \'init\'*)'
22-
echo $' COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur"))'
22+
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--bare" -- "$cur" )'
2323
echo $' ;;'
2424
echo $''
2525
echo $' *)'
26-
echo $' COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur"))'
26+
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version status init commit" -- "$cur" )'
2727
echo $' ;;'
2828
echo $''
2929
echo $' esac'

spec/approvals/cli/test/completely-tester.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ _mygit_completions() {
1818

1919
case "$compline" in
2020
'status'*)
21-
COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur"))
21+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur" )
2222
;;
2323

2424
'commit'*)
25-
COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur"))
25+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur" )
2626
;;
2727

2828
'init'*)
29-
COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur"))
29+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--bare" -- "$cur" )
3030
;;
3131

3232
*)
33-
COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur"))
33+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version status init commit" -- "$cur" )
3434
;;
3535

3636
esac
@@ -48,4 +48,7 @@ COMP_POINT=${#COMP_LINE}
4848
COMP_CWORD=2
4949

5050
_mygit_completions
51-
echo "${COMPREPLY[*]}"
51+
for suggestion in "${COMPREPLY[@]}"; do
52+
echo "$suggestion"
53+
done
54+

spec/approvals/completions/function

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ send_completions() {
1111
echo $''
1212
echo $' case "$compline" in'
1313
echo $' \'generate\'*)'
14-
echo $' COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur"))'
14+
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--help --force" -- "$cur" )'
1515
echo $' ;;'
1616
echo $''
1717
echo $' \'init\'*)'
18-
echo $' COMPREPLY=($(compgen -W "--help" -- "$cur"))'
18+
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help" -- "$cur" )'
1919
echo $' ;;'
2020
echo $''
2121
echo $' *)'
22-
echo $' COMPREPLY=($(compgen -W "--help --version init generate" -- "$cur"))'
22+
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version init generate" -- "$cur" )'
2323
echo $' ;;'
2424
echo $''
2525
echo $' esac'

spec/approvals/completions/script

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ _completely_completions() {
1010

1111
case "$compline" in
1212
'generate'*)
13-
COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur"))
13+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--help --force" -- "$cur" )
1414
;;
1515

1616
'init'*)
17-
COMPREPLY=($(compgen -W "--help" -- "$cur"))
17+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help" -- "$cur" )
1818
;;
1919

2020
*)
21-
COMPREPLY=($(compgen -W "--help --version init generate" -- "$cur"))
21+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version init generate" -- "$cur" )
2222
;;
2323

2424
esac

spec/approvals/completions/script-only-spaces

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ _completely_completions() {
1010

1111
case "$compline" in
1212
'generate'*)
13-
COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur"))
13+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--help --force" -- "$cur" )
1414
;;
1515

1616
'init'*)
17-
COMPREPLY=($(compgen -W "--help" -- "$cur"))
17+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help" -- "$cur" )
1818
;;
1919

2020
esac

0 commit comments

Comments
 (0)