[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how much are "historic" issues with test / [ still an issue
From: |
Christoph Anton Mitterer |
Subject: |
Re: how much are "historic" issues with test / [ still an issue |
Date: |
Tue, 25 May 2021 22:43:26 +0200 |
User-agent: |
Evolution 3.38.3-1 |
On Tue, 2021-05-25 at 15:10 -0400, Chet Ramey wrote:
> > >
> >
>
> > So long story short:
> > - as long as one uses <= 3 arguments, things always works as
> > expected,
> > even if $1 and $3 are variables with arbitrary values set by the
> > user
> >
> > - 4 arguments still works if the first is ! or if $1 and $4 are
> > (
> > and )
> >
> > - anything else >= 4 might is ambiguous, and one should use the
> > forms
> > with multiple test(s) and combine those via ||, &&, and the shell's
> > ( )
> > (i.e. the unquoted parentheses that cause subshell evaluation).
>
> That's a pretty decent summary of the POSIX guidance. The subshells
> can
> throw you off, though, since the word expansions happen in the
> subshell
> and some scripts might expect or need the side effects. In most
> cases,
> you can use { and } instead of the subshells.
I guess { } might be faster, too?
Thanks,
Chris.