Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0426932

Browse files
committed
Further portability hacking in pg_upgrade's test script.
I blew the dust off a Bourne shell (file date 1996, yea verily) andtried to run test.sh with it. It mostly worked, but I found that thetemp-directory creation code introduced by commitbe76a6d was notcompatible, for a couple of reasons: this shell thinks "set -e" shouldforce an exit if a command within backticks fails, and it also thinks codewithin braces should be executed by a sub-shell, meaning that variablesettings don't propagate back up to the parent shell. In view of VictorWagner's report that Solaris is still using pre-POSIX shells, seems likewe oughta make this case work. It's not like the code is any lessidiomatic this way; the prior coding technique appeared nowhere else.(There is a remaining bash-ism here, which is that $RANDOM doesn't dowhat the code hopes in non-bash shells. But the use of $$ elsewhere inthat path should be enough to ensure uniqueness and some amount ofrandomness, 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
1 parent0c0908d commit0426932

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

‎src/bin/pg_upgrade/test.sh

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,18 @@ case $testhost in
4444
# script; the outcome mimics pg_regress.c:make_temp_sockdir().
4545
PGHOST=$PG_REGRESS_SOCK_DIR
4646
if ["x$PGHOST"= x ];then
47-
{
48-
dir=`(umask 077&&
49-
mktemp -d /tmp/pg_upgrade_check-XXXXXX)2>/dev/null`&&
50-
[-d"$dir" ]
51-
}||
52-
{
47+
set +e
48+
dir=`(umask 077&&
49+
mktemp -d /tmp/pg_upgrade_check-XXXXXX)2>/dev/null`
50+
if [!-d"$dir" ];then
5351
dir=/tmp/pg_upgrade_check-$$-$RANDOM
5452
(umask 077&& mkdir"$dir")
55-
}||
56-
{
57-
echo"could not create socket temporary directory in\"/tmp\""
58-
exit 1
59-
}
60-
53+
if [!-d"$dir" ];then
54+
echo"could not create socket temporary directory in\"/tmp\""
55+
exit 1
56+
fi
57+
fi
58+
set -e
6159
PGHOST=$dir
6260
trap'rm -rf "$PGHOST"' 0
6361
trap'exit 3' 1 2 13 15

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp