Skip to content

Commit afe2c52

Browse files
committed
- Support filenames with spaces when <directory> or <file> are used
1 parent d5f7552 commit afe2c52

File tree

12 files changed

+30
-0
lines changed

12 files changed

+30
-0
lines changed

lib/completely/pattern.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ def compgen
4949
@compgen ||= compgen!
5050
end
5151

52+
def filename_action?
53+
actions.include?('-A file') || actions.include?('-A directory')
54+
end
55+
5256
private
5357

5458
def compgen!

lib/completely/templates/template.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
% patterns.each do |pattern|
6161
% next if pattern.empty?
6262
<%= pattern.case_string %>)
63+
% if pattern.filename_action?
64+
compopt -o filenames 2>/dev/null
65+
% end
6366
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen <%= pattern.compgen %> -- "$cur")
6467
;;
6568

spec/approvals/cli/generated-script

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ _mygit_completions() {
6363
;;
6464

6565
'init'*)
66+
compopt -o filenames 2>/dev/null
6667
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_mygit_completions_filter "--bare")" -- "$cur")
6768
;;
6869

spec/approvals/cli/generated-script-alt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ _mycomps() {
6363
;;
6464

6565
'init'*)
66+
compopt -o filenames 2>/dev/null
6667
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_mycomps_filter "--bare")" -- "$cur")
6768
;;
6869

spec/approvals/cli/generated-wrapped-script

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ give_comps() {
6464
echo $' ;;'
6565
echo $''
6666
echo $' \'init\'*)'
67+
echo $' compopt -o filenames 2>/dev/null'
6768
echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_mygit_completions_filter "--bare")" -- "$cur")'
6869
echo $' ;;'
6970
echo $''

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ _mygit_completions() {
7171
;;
7272

7373
'init'*)
74+
compopt -o filenames 2>/dev/null
7475
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_mygit_completions_filter "--bare")" -- "$cur")
7576
;;
7677

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ _mygit_completions() {
7171
;;
7272

7373
'init'*)
74+
compopt -o filenames 2>/dev/null
7475
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_mygit_completions_filter "--bare")" -- "$cur")
7576
;;
7677

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ _mygit_completions() {
7171
;;
7272

7373
'init'*)
74+
compopt -o filenames 2>/dev/null
7475
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_mygit_completions_filter "--bare")" -- "$cur")
7576
;;
7677

spec/approvals/completions/function

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ send_completions() {
5252
echo $''
5353
echo $' case "$compline" in'
5454
echo $' \'generate\'*)'
55+
echo $' compopt -o filenames 2>/dev/null'
5556
echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_completely_completions_filter "--help --force")" -- "$cur")'
5657
echo $' ;;'
5758
echo $''

spec/approvals/completions/script

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ _completely_completions() {
5151

5252
case "$compline" in
5353
'generate'*)
54+
compopt -o filenames 2>/dev/null
5455
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_completely_completions_filter "--help --force")" -- "$cur")
5556
;;
5657

0 commit comments

Comments
 (0)