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

Re: use of "less" in function and interrupt



On Wed, 20 Jul 2016 13:36:33 +0200
Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> With zsh 5.2, if I type:
> 
> zira% sleep 5 | less
> 
> and Ctrl-C immediately after, this interrupts the "sleep 5" and
> everything is fine ("less" ignores the SIGINT).
> 
> But if I use a function:
> 
> zira% tless() { less "$@"; }
> zira% sleep 5 | tless
> 
> then "less" is left stopped in background after I type a key.

Interestingly, I can get this to happen with

sleep 5 | { less }

but not

sleep 5 | ( less )

I'm not sure what that says about job control, which I've never really
understood, but the two cases should be very close as in the second the
shell knows it's about to exit and should exec less without an extra
fork.  I'm guessing that in the failing cases less is somehow being
detached from the terminal while in the other cases it isn't and, when
you quit less, normal service is resumed.

pws



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