Non-portable shell code in pg_upgrade tap tests

From: Victor Wagner <vitus(at)wagner(dot)pp(dot)ru>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Non-portable shell code in pg_upgrade tap tests
Date: 2018-07-20 12:38:20
Message-ID: 20180720153820.69e9ae6c@fafnir.local.vm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Collegues,

I've discovered that in the branch REL_11_STABLE there is shell script
src/bin/pg_upgrade/test.sh which doesn't work under Solaris 10.
(it uses $(command) syntax with is not compatible with original
Solaris /bin/sh)

I was quite surprised that this problem goes unnoticed on big buildfarm,
but after some investigation found out that both Solaris machines in
that buildfarm don't configure postgres with --enable-tap-tests.

Offending code is:

# make sure all directories and files have group permissions, on Unix hosts
# Windows hosts don't support Unix-y permissions.
case $testhost in
MINGW*) ;;
*) if [ $(find ${PGDATA} -type f ! -perm 640 | wc -l) -ne 0 ]; then
echo "files in PGDATA with permission != 640";
exit 1;
fi ;;
esac

case $testhost in
MINGW*) ;;
*) if [ $(find ${PGDATA} -type d ! -perm 750 | wc -l) -ne 0 ]; then
echo "directories in PGDATA with permission != 750";
exit 1;
fi ;;
esac

It is quite easy to replace $() syntax with backticks. Backticks are
not nestable and considered unsafe by modern shell scripting style
guides, but they do work with older shells.

--

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-07-20 14:25:47 Re: Non-portable shell code in pg_upgrade tap tests
Previous Message Robert Haas 2018-07-20 12:38:09 Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled.