Skip to content

Commit 137f3b0

Browse files
committed
Support fish completion with env vars in the path
Fixes #1214 Fixes #1306 Signed-off-by: Marc Khouzam <[email protected]>
1 parent 0b1a206 commit 137f3b0

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

fish_completions.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,13 @@ function __%[1]s_perform_completion
4343
end
4444
__%[1]s_debug "emptyArg: $emptyArg"
4545
46-
if not type -q "$args[1]"
47-
# This can happen when "complete --do-complete %[2]s" is called when running this script.
48-
__%[1]s_debug "Cannot find $args[1]. No completions."
49-
return
50-
end
51-
5246
set requestComp "$args[1] %[3]s $args[2..-1] $emptyArg"
5347
__%[1]s_debug "Calling $requestComp"
5448
55-
set results (eval $requestComp 2> /dev/null)
49+
# Call the command as a sub-shell so that we can redirect any errors
50+
# For example, if $requestComp has an unmatched quote
51+
# https://github.com/spf13/cobra/issues/1214
52+
set results (fish -c "$requestComp" 2> /dev/null)
5653
set comps $results[1..-2]
5754
set directiveLine $results[-1]
5855

0 commit comments

Comments
 (0)