From 4d5090a3801d9259b7d71ce5a58cc5b82304c291 Mon Sep 17 00:00:00 2001 From: Suraj Pillai <85.suraj@gmail.com> Date: Fri, 24 Sep 2021 18:39:12 -0400 Subject: [PATCH] Fix issue with flags when a switch value is enclosed in quotes When a flag's value is enclosed in quotes, the command was breaking due to lack of an escape sequence. The issue has been fixed. --- fzf-key-bindings.bash | 2 +- fzf-key-bindings.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fzf-key-bindings.bash b/fzf-key-bindings.bash index dba5242..62faf5e 100644 --- a/fzf-key-bindings.bash +++ b/fzf-key-bindings.bash @@ -63,7 +63,7 @@ __fzf_sfdx_flags__(){ local selected="$1" local fullcmd="" for i in "${@:2}" - do fullcmd+=" $i" + do fullcmd+=" ${i//\"/\\\\\\\"}" #we have to triple escape the double quotes here as it will be used within double quotes again in the command below done local ret=`cat ~/.sfdxcommands.json | jq -r ".[] | select(.id==\"$selected\") | .flags | keys[]" | $(__fzfcmd) -m --bind 'ctrl-z:ignore,alt-j:preview-down,alt-k:preview-up' --preview='cat ~/.sfdxcommands.json | jq -r ".[] | select(.id==\"'$selected'\") | .flags | to_entries[] | select (.key==\""{}"\") | [\"Command:\n'"$fullcmd"'\n\",\"Flag Description:\",.value][]"' --preview-window='right:wrap'` echo "${ret//$'\n'/ --}" diff --git a/fzf-key-bindings.zsh b/fzf-key-bindings.zsh index 14be3c7..2e01642 100644 --- a/fzf-key-bindings.zsh +++ b/fzf-key-bindings.zsh @@ -113,7 +113,7 @@ __fzf_sfdx_flags(){ local selected="$1" local fullcmd="" for i in "${@:2}" - do fullcmd+=" $i" + do fullcmd+=" ${i//\"/\\\\\\\"}" #we have to triple escape the double quotes here as it will be used within double quotes again in the command below done local ret=`cat ~/.sfdxcommands.json | jq -r ".[] | select(.id==\"$selected\") | .flags | keys[]" | $(__fzfcmd) -m --bind='ctrl-z:ignore,alt-j:preview-down,alt-k:preview-up' --preview='cat ~/.sfdxcommands.json | jq -r ".[] | select(.id==\"'$selected'\") | .flags | to_entries[] | select (.key==\""{}"\") | [\"Command:\n'"$fullcmd"'\n\",\"Flag Description:\",.value][]"' --preview-window='right:wrap'` echo "${ret//$'\n'/ --}"