junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
61.81k stars 2.35k forks source link

Using bind with an echo output, the variable assignment no longer works #3872

Closed cmaahs closed 2 weeks ago

cmaahs commented 2 weeks ago

Checklist

Output of fzf --version

0.53.0 (brew)

OS

Shell

Problem / Steps to reproduce

With version 0.53.0 this is the behavior I am experiencing:

% KUBE_CLUSTER=$(echo "HEADER\n------\ncluster1\ncluster2" | fzf --header-lines=2 --bind 'enter:execute(echo {+1})+abort'); echo "\n~${KUBE_CLUSTER}~\n" cluster1

~~

% KUBE_CLUSTER=$(echo "HEADER\n------\ncluster1\ncluster2" | fzf --header-lines=2 --bind 'enter:execute(echo {+1})+abort'); echo "\n~${KUBE_CLUSTER}~\n" cluster2

~~

I rolled back to 0.52.1 and tested with the same:

% KUBE_CLUSTER=$(echo "HEADER\n------\ncluster1\ncluster2" | fzf --header-lines=2 --bind 'enter:execute(echo {+1})+abort'); echo "\n~${KUBE_CLUSTER}~\n"

~cluster1~

% KUBE_CLUSTER=$(echo "HEADER\n------\ncluster1\ncluster2" | fzf --header-lines=2 --bind 'enter:execute(echo {+1})+abort'); echo "\n~${KUBE_CLUSTER}~\n"

~cluster2~

As you can see, under 0.52.1, the selected line is being assigned to the varible, and with 0.53.0, the value is being outputted directly, which feels a bit like it is being outputted on stderr, and the variable ends up empty.

junegunn commented 2 weeks ago

See #3865

In your case, just replace execute+abort with become.

cmaahs commented 2 weeks ago

I swear to you that I searched open and closed issue for bind, perhaps I was too restrictive in my search terms. Thanks for the push in the right direction.