Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c737a2e

Browse files
committed
Work around NetBSD shell issue in pg_upgrade test script.
The NetBSD shell apparently returns non-zero from an unset command if the variable is already unset. This matters when, as in pg_upgrade's test.sh, we are working under 'set -e'. To protect against this, we first set the PG variables to an empty string before unsetting them completely. Error found on buildfarm member coypu, solution from Rémi Zara.
1 parent c2b51cf commit c737a2e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

contrib/pg_upgrade/test.sh

+12-8
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,18 @@ mkdir "$logdir"
7676

7777
# Clear out any environment vars that might cause libpq to connect to
7878
# the wrong postmaster (cf pg_regress.c)
79-
unset PGDATABASE
80-
unset PGUSER
81-
unset PGSERVICE
82-
unset PGSSLMODE
83-
unset PGREQUIRESSL
84-
unset PGCONNECT_TIMEOUT
85-
unset PGHOST
86-
unset PGHOSTADDR
79+
#
80+
# Some shells, such as NetBSD's, return non-zero from unset if the variable
81+
# is already unset. Since we are operating under 'set -e', this causes the
82+
# script to fail. To guard against this, set them all to an empty string first.
83+
PGDATABASE=""; unset PGDATABASE
84+
PGUSER=""; unset PGUSER
85+
PGSERVICE=""; unset PGSERVICE
86+
PGSSLMODE="" unset PGSSLMODE
87+
PGREQUIRESSL=""; unset PGREQUIRESSL
88+
PGCONNECT_TIMEOUT=""; unset PGCONNECT_TIMEOUT
89+
PGHOST="" unset PGHOST
90+
PGHOSTADDR=""; unset PGHOSTADDR
8791

8892
# Select a non-conflicting port number, similarly to pg_regress.c
8993
PG_VERSION_NUM=`grep '#define PG_VERSION_NUM' $newsrc/src/include/pg_config.h | awk '{print $3}'`

0 commit comments

Comments
 (0)