Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: less with subprocess
- X-seq: zsh-users 27152
- From: Dominik Vogt <dominik.vogt@xxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: less with subprocess
- Date: Tue, 28 Sep 2021 00:31:43 +0100
- Archived-at: <https://zsh.org/users/27152>
- In-reply-to: <CAP+y1xDdPi=DHR0KNrdCRiroC-54ev8HhfPW5O+59ap1COLBSg@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- Mail-followup-to: zsh-users@xxxxxxx
- References: <CAP+y1xAUzYHRMKGuJR2rBNvWY4ew6+2G-PyZagZHhaqu1sfXow@mail.gmail.com> <CAN=4vMpNGbOThNtxpHcUHc=UkOJpW-zPgOOFLku=SW+s9c7+Wg@mail.gmail.com> <CAH+w=7aUMP3yw8L_Q51JU5AO1yrrCpVigkoOEagTO+iuKZ8R=A@mail.gmail.com> <CAH+w=7bCC--sF2_FGoB-B17RxGoSzcVTzRbuddqOnU_gtO=pXQ@mail.gmail.com> <CAP+y1xDdPi=DHR0KNrdCRiroC-54ev8HhfPW5O+59ap1COLBSg@mail.gmail.com>
- Reply-to: dominik.vogt@xxxxxx
On Tue, Sep 28, 2021 at 12:57:02AM +0200, Pier Paolo Grassi wrote:
> I am trying some variations based on suggestions from the page Roman linked:
>
> (trap 'kill -PIPE 0' INT; less -f -+F <(eval "sleep 100" ))
> /proc/self/fd/11 lines 1--1...skipping...
> /proc/self/fd/11 lines 1--1...skipping...
> /proc/self/fd/11 lines 1--1...skipping...
> /proc/self/fd/11 lines 1--1...skipping...
> /proc/self/fd/11 lines 1--1...skipping...
> /proc/self/fd/11 lines 1--1...skipping...
>
> the "skipping lines" is what is printed, I assume by less, when I press
> ctrl-c
> I can confirm that using ctrl-z and kill % is able to successfully get rid
> of the process, but it seems kind of an emergency measure to me, not what I
> would like to be my routine.
> It seems to me that less is eating the ctrl-c, so the trap is never called,
It's still not clear to me what you're trying to accomplish. You
mentioned two issues:
1) less does not react to SIGINT before it receives any input.
Actually, less (v487) does not react to SIGINT before it
receives a full screen of input. A workaround is to print some
dummy input before the real command. Something like
less -f <( repeat $LINES; echo ""; ls -lR / )
2) You want "ctrl-c" to stop less from reading input and go into
"view" mode, then press "F" to go back to "listening" mode? If
so, what are these experiments with "SIGPIPE" trying to do?
If you want less to work on the command output like it would
work on a growing file, why don't you just *write* that output
to a file and run less on that?
alias -g LF="> $HOME/tmp/less-input.$$ & less $HOME/tmp/less-input.$$; kill %; rm $HOME/tmp/less-input.$$"
Run it with
ls -lR / 2> /dev/null LF
^^^^
The global alias saves you the effort of typing all that stuff
with the tempfile and less after the command.
(You really want to use a private path for the tempfiles
because the alias would be vulnerable to symlink attacks when used
in a publicly writeable directory.)
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
Messages sorted by:
Reverse Date,
Date,
Thread,
Author