aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-07-21 15:40:51 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-07-21 15:40:51 -0400
commitdfbad3f454103e7cd379595fdcdce3952effbd5f (patch)
tree526780b6c3b2ea375e18613cd294ad1c9db25e1d /src
parent821200405cc3f25fda28c5f58d17d640e25559b8 (diff)
downloadpostgresql-dfbad3f454103e7cd379595fdcdce3952effbd5f.tar.gz
postgresql-dfbad3f454103e7cd379595fdcdce3952effbd5f.zip
Further portability hacking in pg_upgrade's test script.
I blew the dust off a Bourne shell (file date 1996, yea verily) and tried to run test.sh with it. It mostly worked, but I found that the temp-directory creation code introduced by commit be76a6d39 was not compatible, for a couple of reasons: this shell thinks "set -e" should force an exit if a command within backticks fails, and it also thinks code within braces should be executed by a sub-shell, meaning that variable settings don't propagate back up to the parent shell. In view of Victor Wagner's report that Solaris is still using pre-POSIX shells, seems like we oughta make this case work. It's not like the code is any less idiomatic this way; the prior coding technique appeared nowhere else. (There is a remaining bash-ism here, which is that $RANDOM doesn't do what the code hopes in non-bash shells. But the use of $$ elsewhere in that path should be enough to ensure uniqueness and some amount of randomness, so I think it's okay as-is.) Back-patch to all supported branches, as the previous commit was. Discussion: https://postgr.es/m/20180720153820.69e9ae6c@fafnir.local.vm
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_upgrade/test.sh22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/bin/pg_upgrade/test.sh b/src/bin/pg_upgrade/test.sh
index 31a8581b146..af428a9df80 100644
--- a/src/bin/pg_upgrade/test.sh
+++ b/src/bin/pg_upgrade/test.sh
@@ -42,20 +42,18 @@ case $testhost in
# script; the outcome mimics pg_regress.c:make_temp_sockdir().
PGHOST=$PG_REGRESS_SOCK_DIR
if [ "x$PGHOST" = x ]; then
- {
- dir=`(umask 077 &&
- mktemp -d /tmp/pg_upgrade_check-XXXXXX) 2>/dev/null` &&
- [ -d "$dir" ]
- } ||
- {
+ set +e
+ dir=`(umask 077 &&
+ mktemp -d /tmp/pg_upgrade_check-XXXXXX) 2>/dev/null`
+ if [ ! -d "$dir" ]; then
dir=/tmp/pg_upgrade_check-$$-$RANDOM
(umask 077 && mkdir "$dir")
- } ||
- {
- echo "could not create socket temporary directory in \"/tmp\""
- exit 1
- }
-
+ if [ ! -d "$dir" ]; then
+ echo "could not create socket temporary directory in \"/tmp\""
+ exit 1
+ fi
+ fi
+ set -e
PGHOST=$dir
trap 'rm -rf "$PGHOST"' 0
trap 'exit 3' 1 2 13 15