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

Re: PATCH: make the W02 test not take a full minute on linux



On Thu, Jun 11, 2026 at 10:00 PM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Thu, Jun 11, 2026 at 11:05 AM Bart Schaefer
> <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > % { [[ -t 0 ]] & print -u2 terminal } <>/dev/null
>
> Obviously a second & got dropped there somehow, so for completeness:
>
> % { [[ -t 0 ]] && print -u2 terminal } >/dev/null
> terminal
> % { [[ -t 0 ]] && print -u2 terminal } <>/dev/null
> %

<> just means open as read/write, it still only opens fd 0. My earlier
statement was slightly incorrect though because I had assumed it
opened only fd 1 and changed it to just a >, and added the </dev/null.
But in fact what I would have needed is <>/dev/null and >/dev/null. It
is much clearer to just use > 2> and <, since nobody is reading or
writing anyway. We need to close all three fds to have the test go
fast, so we need three redirection operators.

{ [[ -t 1 ]] && print -u2 terminal } <>/dev/null
terminal

-- 
Mikael Magnusson




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