Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fish completions: fix double-evaluation of commandline #2095

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Apr 26, 2024

  1. fish completions: fix double-evaluation of commandline

    We capture the commandline tokens using fish's "commandline --tokenize" (-o).
    Given a commandline of
    
    	some-cobra-command 'some argument $(123)' "$HOME"
    
    into three arguments while removing the quotes
    
    	some-cobra-command
    	some argument $(123)
    	$HOME
    
    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 upcoming fish 3.8 has a new flag, "commandline -x"
    which will expand variables like $HOME properly, see
    fish-shell/fish-shell#10212 Use that if
    available.
    
    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
    krobelus committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    4e07448 View commit details
    Browse the repository at this point in the history