Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: less with subprocess

I tried:

LF () { () { cat >|$1 &! less $1 ; kill $! } =(:) }

find | LF

unfortunately when hitting F then ctrl-c in less the find process is immediately killed

Pier Paolo Grassi

Il giorno mer 29 set 2021 alle ore 16:15 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> ha scritto:
On Wed, Sep 29, 2021 at 6:02 AM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> cventin% LF () { () { cat >$1 &! less $1 ; kill $! } =(:) }
> cventin% echo | LF
> (anon):kill: kill 27684 failed: no such process

Yeah, if you use it with a process that produces very little output,
the kill will fail.  But there's no point in using it in that case.
Redirect stderr of kill if this bothers you.

> And
> cventin% (sleep 1; echo foo) | LF
> gives an empty file in "less"

Yes, you have to hit "F" in less to reload / wait for the file
contents.  I suppose "less +F" might be preferable.  There are still
some signal handling issues with having a subshell on the left side of
the pipe, which might very well indicate that there is still a zsh (or
"less"?) bug with signal propagation.

Messages sorted by: Reverse Date, Date, Thread, Author