[cfarm-users] POSIX shells (was: Automated deployment across multiple cfarm hosts)
Jacob Bachmeyer
jcb62281 at gmail.com
Mon Sep 16 04:40:07 CEST 2024
Denis Ovsienko via cfarm-users wrote:
> On Sun, 15 Sep 2024 15:39:18 +0000
> Peter Gutmann via cfarm-users <cfarm-users at lists.tetaneutral.net> wrote:
>
>
>> (OK, it's not quite that bad, but several things are pre-Posix at
>> least, e.g. /bin/sh doesn't understand "$(...)" but requires `...`).
>>
>
> I ran into this particular thing after following the advice of
> shellcheck and replacing `` with $(), which promptly broke the script
> on Solaris 10, which is supposed to be POSIX-compliant, at least in the
> shell department. As far as I remember, eventually the explanation was
> that in Solaris before 11 /bin/sh conformed to an older version of POSIX
> that does not have $().
I think that there *is* a POSIX shell on Solaris 10, it is just that
/bin/sh is not that shell. I just checked and running "PATH=`getconf
PATH` command -v sh" returns "/usr/xpg4/bin/sh" on cfarm210 and
"/usr/bin/sh" on cfarm111 so that might be short way to find a POSIX
shell on both Solaris 10 and AIX 7.1. In fact, even /bin/sh on cfarm111
accepts $() notation.
> So my script ended up using `` again and
> disabling shellcheck warning SC2006.
Other shellcheck warnings that I have had to generally inhibit include
SC2268 and SC2003 (Solaris 10 /bin/sh needs expr(1) instead of POSIX
arithmetic). The "dejagnu" general command launcher script in DejaGnu
has had considerable adaptation to handle some of these weirdnesses
found at the CFarm and otherwise probably would not work on those systems.
(Very interestingly, now that I check, "PATH=`getconf PATH` command -v
awk" on cfarm210 finds /usr/xpg4/bin/awk, which is a POSIX Awk, while
/usr/bin/awk on that system is non-POSIX. I think that I may need to
revise the dejagnu(1) launcher in light of this information. (It
currently directly looks in /usr/xpg4/bin for an awk(1) before searching
$PATH, a quick workaround to make it work on cfarm210.) It would also
be nice if command scripts could assume a POSIX shell, even if the
launcher itself cannot.) (Also interestingly, "command -p -v awk" finds
/usr/bin/awk on cfarm210; apparently command(1) in Solaris 10 either
ignores the "-p" option or does not use the same "system tools path"
value that getconf(1) returns.)
-- Jacob
More information about the cfarm-users
mailing list