zsh-users
 help / Atom feed
* Weird behavior with redirecting stdin
@ 2019-09-02 13:58 Aryn Starr
  2019-09-02 14:00 ` Pier Paolo Grassi
  2019-09-02 14:36 ` Roman Perepelitsa
  0 siblings, 2 replies; 3+ messages in thread
From: Aryn Starr @ 2019-09-02 13:58 UTC (permalink / raw)
  To: zsh-users

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 ...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Weird behavior with redirecting stdin
  2019-09-02 13:58 Weird behavior with redirecting stdin Aryn Starr
@ 2019-09-02 14:00 ` Pier Paolo Grassi
  2019-09-02 14:36 ` Roman Perepelitsa
  1 sibling, 0 replies; 3+ messages in thread
From: Pier Paolo Grassi @ 2019-09-02 14:00 UTC (permalink / raw)
  To: Aryn Starr; +Cc: Zsh-Users List

[-- 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 ...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Weird behavior with redirecting stdin
  2019-09-02 13:58 Weird behavior with redirecting stdin Aryn Starr
  2019-09-02 14:00 ` Pier Paolo Grassi
@ 2019-09-02 14:36 ` Roman Perepelitsa
  1 sibling, 0 replies; 3+ messages in thread
From: Roman Perepelitsa @ 2019-09-02 14:36 UTC (permalink / raw)
  To: Aryn Starr; +Cc: Zsh Users

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-02 13:58 Weird behavior with redirecting stdin Aryn Starr
2019-09-02 14:00 ` Pier Paolo Grassi
2019-09-02 14:36 ` Roman Perepelitsa

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox