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

Commit ae8a2c3

Browse files
committed
Make the world safe for QNX's busted shell ...
1 parent 69b323f commit ae8a2c3

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

src/test/regress/regress.sh

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.50 2000/05/16 02:14:15 tgl Exp $
2+
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.51 2000/05/24 22:32:58 tgl Exp $
33
#
44
if [ $# -eq 0 ]; then
55
echo "Syntax: $0 <hostname> [extra-tests]"
@@ -41,17 +41,27 @@ FRONTEND="psql $HOSTLOC -a -q -X"
4141
# testname/hostnamepattern=substitutefile
4242
# where the hostnamepattern is evaluated per the rules of expr(1) --- namely,
4343
# it is a standard regular expression with an implicit ^ at the start.
44+
#
45+
# The tempfile hackery is needed because some shells will run the loop
46+
# inside a subshell, whereupon shell variables set therein aren't seen
47+
# outside the loop :-(
4448
# ----------
45-
SUBSTLIST=""
46-
RESULTMAP=`cat resultmap`
47-
for LINE in $RESULTMAP
49+
TMPFILE="matches.$$"
50+
cat /dev/null > $TMPFILE
51+
while read LINE
4852
do
4953
HOSTPAT=`expr "$LINE" : '.*/\(.*\)='`
5054
if [ `expr "$hostname" : "$HOSTPAT"` -ne 0 ]
5155
then
52-
SUBSTLIST="$SUBSTLIST $LINE"
56+
# remove hostnamepattern from line so that there are no shell
57+
# wildcards in SUBSTLIST; else later 'for' could expand them!
58+
TESTNAME=`expr "$LINE" : '\(.*\)/'`
59+
SUBST=`echo "$LINE" | sed 's/^.*=//'`
60+
echo "$TESTNAME=$SUBST" >> $TMPFILE
5361
fi
54-
done
62+
done <resultmap
63+
SUBSTLIST=`cat $TMPFILE`
64+
rm -f $TMPFILE
5565

5666
if [ -d ./obj ]; then
5767
cd ./obj
@@ -97,7 +107,7 @@ fi
97107
fi
98108

99109
echo "=============== running regression queries... ================="
100-
echo "" > regression.diffs
110+
cat /dev/null > regression.diffs
101111

102112
if [ "x$hostname" = "xi386-pc-qnx" ]; then
103113
DIFFOPT="-b"
@@ -123,7 +133,7 @@ do
123133
EXPECTED="expected/${tst}.out"
124134
for LINE in $SUBSTLIST
125135
do
126-
if [ `expr "$LINE" : "$tst/"` -ne 0 ]
136+
if [ `expr "$LINE" : "$tst="` -ne 0 ]
127137
then
128138
SUBST=`echo "$LINE" | sed 's/^.*=//'`
129139
EXPECTED="expected/${SUBST}.out"

src/test/regress/run_check.sh

+19-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
#
3-
# $Header: /cvsroot/pgsql/src/test/regress/Attic/run_check.sh,v 1.18 2000/05/18 16:11:39 momjian Exp $
3+
# $Header: /cvsroot/pgsql/src/test/regress/Attic/run_check.sh,v 1.19 2000/05/24 22:32:59 tgl Exp $
44

55
# ----------
66
# Check call syntax
@@ -104,18 +104,27 @@ FRONTEND="$BINDIR/psql $HOSTLOC -a -q -X"
104104
# testname/hostnamepattern=substitutefile
105105
# where the hostnamepattern is evaluated per the rules of expr(1) --- namely,
106106
# it is a standard regular expression with an implicit ^ at the start.
107+
#
108+
# The tempfile hackery is needed because some shells will run the loop
109+
# inside a subshell, whereupon shell variables set therein aren't seen
110+
# outside the loop :-(
107111
# ----------
108-
SUBSTLIST=""
109-
exec 4<resultmap
110-
while read LINE <&4
112+
TMPFILE="matches.$$"
113+
cat /dev/null > $TMPFILE
114+
while read LINE
111115
do
112116
HOSTPAT=`expr "$LINE" : '.*/\(.*\)='`
113117
if [ `expr "$hostname" : "$HOSTPAT"` -ne 0 ]
114118
then
115-
SUBSTLIST="$SUBSTLIST $LINE"
119+
# remove hostnamepattern from line so that there are no shell
120+
# wildcards in SUBSTLIST; else later 'for' could expand them!
121+
TESTNAME=`expr "$LINE" : '\(.*\)/'`
122+
SUBST=`echo "$LINE" | sed 's/^.*=//'`
123+
echo "$TESTNAME=$SUBST" >> $TMPFILE
116124
fi
117-
done
118-
exec 4<&-
125+
done <resultmap
126+
SUBSTLIST=`cat $TMPFILE`
127+
rm -f $TMPFILE
119128

120129
# ----------
121130
# Catch SIGINT and SIGTERM to shutdown the postmaster
@@ -258,8 +267,8 @@ fi
258267
# Run the regression tests specified in the ./sql/run_check.tests file
259268
# ----------
260269
echo "=============== Running regression queries... ================"
261-
echo "" > regression.diffs
262-
echo "" > regress.out
270+
cat /dev/null > regression.diffs
271+
cat /dev/null > regress.out
263272

264273
if [ "x$hostname" = "xi386-pc-qnx" ]; then
265274
DIFFOPT="-b"
@@ -439,7 +448,7 @@ lno=0
439448
EXPECTED="expected/${name}.out"
440449
for LINE in $SUBSTLIST
441450
do
442-
if [ `expr "$LINE" : "$name/"` -ne 0 ]
451+
if [ `expr "$LINE" : "$name="` -ne 0 ]
443452
then
444453
SUBST=`echo "$LINE" | sed 's/^.*=//'`
445454
EXPECTED="expected/${SUBST}.out"

0 commit comments

Comments
 (0)