diff --git a/src/bin/pg_upgrade/test.sh b/src/bin/pg_upgrade/test.sh index 49849b371b..eef6be2a5c 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