Skip to content

Commit eabe4e5

Browse files
committed
fish completions: fix double-evaluation of commandline
We capture the commandline tokens using fish's "commandline --tokenize" (-o). That function turns echo 'some argument $(123)' into two arguments while removing the quotes echo some argument $(123) Later we pass "some argument $(123)" without quotes to the shell's "eval". This is wrong and causes spurious evaluation of the parenthesis as command substitution. Fix this by escaping the arguments. The downside of this change is that things like "$HOME" or "~" will no longer be escaped. Changing this requires changes in fish, which I'm working on. Reproduce the issue by pasting the completion script at fish-shell/fish-shell#10194 (comment) to a file "grafana-manager.fish" and running function grafana-manager; end source grafana-manager.fish Then type (without pressing Enter) grafana-manager public-dashboards delete --organization-id 3 --dashboard-name "k8s (public)" <TAB> Fixes fish-shell/fish-shell#10194
1 parent 0dec88e commit eabe4e5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fish_completions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function __%[1]s_perform_completion
4545
__%[1]s_debug "Starting __%[1]s_perform_completion"
4646
4747
# Extract all args except the last one
48-
set -l args (commandline -opc)
48+
set -l args (commandline -opc | string escape)
4949
# Extract the last arg and escape it in case it is a space
5050
set -l lastArg (string escape -- (commandline -ct))
5151

0 commit comments

Comments
 (0)