Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: less with subprocess
- X-seq: zsh-users 27153
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: dominik.vogt@xxxxxx, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: less with subprocess
- Date: Mon, 27 Sep 2021 17:41:59 -0700
- Archived-at: <https://zsh.org/users/27153>
- In-reply-to: <20210927233143.GA16620@gmx.de>
- List-id: <zsh-users.zsh.org>
- 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> <20210927233143.GA16620@gmx.de>
On Mon, Sep 27, 2021 at 4:33 PM Dominik Vogt <dominik.vogt@xxxxxx> wrote:
>
> alias -g LF="> $HOME/tmp/less-input.$$ & less $HOME/tmp/less-input.$$; kill %; rm $HOME/tmp/less-input.$$"
Nice, but how about:
alias -g LF='| () { cat >$1 &! less $1 ; kill $! } =(:)'
The use of &! silently backgrounds and disassociates cat so that it
can't be terminal-interrupted, and the anonymous function re-uses the
automatically created (and automatically removed) file name from =(:).
When less exits, "kill $!" terminates cat.
> (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.)
Not unreasonable advice, but using the =(...) substitution removes
much of the danger (and most people aren't on shared servers any
more). If paranoid, TMPPREFIX can be set to a private path to assure
you're always using it with process substitutions.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author