[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: not sure about number comparison
From: |
Lawrence Velázquez |
Subject: |
Re: not sure about number comparison |
Date: |
Sun, 19 Feb 2023 16:20:43 -0500 |
User-agent: |
Cyrus-JMAP/3.9.0-alpha0-156-g081acc5ed5-fm-20230206.001-g081acc5e |
On Sun, Feb 19, 2023, at 2:50 PM, Greg Wooledge wrote:
> On Sun, Feb 19, 2023 at 02:15:41PM -0500, Roger wrote:
>> Any notes on POSIX compliance? Or as it sounds if most are doing it, is it
>> already considered mostly POSIX compliant?
>
> I went out of my way to say "bash" repeatedly, because (( )) and [[ ]]
> are both bash extensions.
>
> If you have to do this in POSIX, you only have test and [ ].
>
> if test "$x" -lt 5; then
> echo "too small"
I guess one could do this in a POSIX shell. It might even be
sensible, if the expression were sufficiently complex.
if test "$((x < 5))" -ne 0; then
echo 'too small'
fi
--
vq