Skip to content

Commit 5e5d131

Browse files
committed
Be more paranoid about quoting in pg_upgrade's test script.
Double-quote $PGDATA in "find" commands introduced by commit da9b580, in case that path contains spaces or other special characters. Adjust a few other places so that quoting is done more consistently. None of the others are actual bugs AFAICS, but it's confusing to readers if the same thing is done differently in different places. Noted by Tels. Discussion: https://postgr.es/m/c96303c04c360bbedaa04f90f515745b.squirrel@sm.webmail.pair.com
1 parent e610568 commit 5e5d131

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/bin/pg_upgrade/test.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ case $testhost in
6565
;;
6666
esac
6767

68-
POSTMASTER_OPTS="-F -c listen_addresses=$LISTEN_ADDRESSES -k \"$PGHOST\""
68+
POSTMASTER_OPTS="-F -c listen_addresses=\"$LISTEN_ADDRESSES\" -k \"$PGHOST\""
6969
export PGHOST
7070

7171
# don't rely on $PWD here, as old shells don't set it
@@ -107,8 +107,8 @@ newsrc=`cd ../../.. && pwd`
107107
PATH=$bindir:$PATH
108108
export PATH
109109

110-
BASE_PGDATA=$temp_root/data
111-
PGDATA="$BASE_PGDATA.old"
110+
BASE_PGDATA="$temp_root/data"
111+
PGDATA="${BASE_PGDATA}.old"
112112
export PGDATA
113113
rm -rf "$BASE_PGDATA" "$PGDATA"
114114

@@ -224,25 +224,25 @@ if [ -n "$pg_dumpall1_status" ]; then
224224
exit 1
225225
fi
226226

227-
PGDATA=$BASE_PGDATA
227+
PGDATA="$BASE_PGDATA"
228228

229229
standard_initdb 'initdb'
230230

231-
pg_upgrade $PG_UPGRADE_OPTS -d "${PGDATA}.old" -D "${PGDATA}" -b "$oldbindir" -B "$bindir" -p "$PGPORT" -P "$PGPORT"
231+
pg_upgrade $PG_UPGRADE_OPTS -d "${PGDATA}.old" -D "$PGDATA" -b "$oldbindir" -B "$bindir" -p "$PGPORT" -P "$PGPORT"
232232

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

243243
case $testhost in
244244
MINGW*) ;;
245-
*) if [ `find ${PGDATA} -type d ! -perm 750 | wc -l` -ne 0 ]; then
245+
*) if [ `find "$PGDATA" -type d ! -perm 750 | wc -l` -ne 0 ]; then
246246
echo "directories in PGDATA with permission != 750";
247247
exit 1;
248248
fi ;;

0 commit comments

Comments
 (0)