"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Re: POSIX shell portability fixes under regress/
To:
Ryo ONODERA <ryo@tetera.org>
Cc:
gameoftrees@openbsd.org
Date:
Mon, 28 Dec 2020 19:19:58 +0100

Download raw body.

Thread
Ryo ONODERA:

> Some shell scripts under regress/ directory
> use [s1 == s2] syntax to compare strings.
> In POSIX way, this is defined as [s1 = s2].
> See:
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html

There are a lot of things in the regression scripts that are not
POSIX.  Such as "local" variables.  I'm not sure it makes much sense
to fix usages that work just fine on all platforms that Got is
likely to be ported to.

The biggest actual portability headache is the use of "sed -i".

> -	if [ "$ret" == "0" ]; then
> +	if [ "$ret" = "0" ]; then

Numerical comparisons should use -eq in the first place.

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de