With these functions: ``` fcm () { # Function for selecting a command interactively echo ${(F)commands} | fzf } teec () { # Dumbed down version of a function that both echoes and copies to clipboard. (Current toy version just echoes.) local out="$(</dev/stdin)" print -r -- "$out" } ``` I can do `fcm | teec` and it works correctly. However, if I change `teec` to this: ``` teec () { echo 'echo hi' | { eval "$(</dev/stdin)" } local out="$(</dev/stdin)" print -r -- "$out" } ``` Then running `fcm | teec` hangs (after printing `hi`) and doesn’t even get interrupted with ^D or ^C. I don’t understand why these problems occur at all, and I have no idea how to go about fixing them ...
[-- Attachment #1: Type: text/plain, Size: 976 bytes --] hello, anyone has suggestions on this? regards Il giorno lun 2 set 2019 alle ore 15:59 Aryn Starr < whereislelouch@icloud.com> ha scritto: > With these functions: > > ``` > fcm () { > # Function for selecting a command interactively > echo ${(F)commands} | fzf > } > > teec () { > # Dumbed down version of a function that both echoes and copies to > clipboard. (Current toy version just echoes.) > local out="$(</dev/stdin)" > print -r -- "$out" > } > ``` > > I can do `fcm | teec` and it works correctly. > However, if I change `teec` to this: > > ``` > teec () { > echo 'echo hi' | { eval "$(</dev/stdin)" } > local out="$(</dev/stdin)" > print -r -- "$out" > } > ``` > > Then running `fcm | teec` hangs (after printing `hi`) and doesn’t even get > interrupted with ^D or ^C. > I don’t understand why these problems occur at all, and I have no idea how > to go about fixing them ...
On Mon, Sep 2, 2019 at 3:59 PM Aryn Starr <whereislelouch@icloud.com> wrote:
> Then running `fcm | teec` hangs (after printing `hi`) and doesn’t even get interrupted with ^D or ^C.
> I don’t understand why these problems occur at all, and I have no idea how to go about fixing them ...
I don't know what's going on but here's a simplified test case that hangs:
echo | fzf | { /bin/true; : "$(cat)" }
This also hangs:
fzf | { /bin/true; : "$(cat)" }
I think this might be caused by fzf getting suspended when it tries to
write to the terminal. I'm just speculating though.
Roman.