Fix use of "export" to work with traditional shells.
[pspp-builds.git] / tests / bugs / match-files-scratch.sh
1 #!/bin/sh
2
3 # This program tests for a bug which caused MATCH FILES to crash
4 # when used with scratch variables.
5
6
7 TEMPDIR=/tmp/pspp-tst-$$
8 TESTFILE=$TEMPDIR/`basename $0`.pspp
9
10 here=`pwd`;
11
12 # ensure that top_srcdir is absolute
13 cd $top_srcdir; top_srcdir=`pwd`
14
15 STAT_CONFIG_PATH=$top_srcdir/config
16 export STAT_CONFIG_PATH
17
18
19 cleanup()
20 {
21      rm -rf $TEMPDIR
22 }
23
24
25 fail()
26 {
27     echo $activity
28     echo FAILED
29     cleanup;
30     exit 1;
31 }
32
33
34 no_result()
35 {
36     echo $activity
37     echo NO RESULT;
38     cleanup;
39     exit 2;
40 }
41
42 pass()
43 {
44     cleanup;
45     exit 0;
46 }
47
48 mkdir -p $TEMPDIR
49
50 cd $TEMPDIR
51
52 activity="create program"
53 cat > $TESTFILE <<EOF
54 DATA LIST LIST /w * x * y * .
55 BEGIN DATA
56 4 5 6
57 1 2 3
58 END DATA.
59
60 COMPUTE j=0.
61 LOOP #k = 1 to 10.
62 COMPUTE j=#k + j.
63 END LOOP.
64
65 MATCH FILES FILE=* /DROP=w.
66 LIST.
67 FINISH.
68
69 EOF
70 if [ $? -ne 0 ] ; then no_result ; fi
71
72 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
73 if [ $? -ne 0 ] ; then no_result ; fi
74
75
76 diff -b -B -w $TEMPDIR/pspp.list - << EOF
77 1.1 DATA LIST.  Reading free-form data from the command file.
78 +--------+------+
79 |Variable|Format|
80 #========#======#
81 |w       |F8.0  |
82 |x       |F8.0  |
83 |y       |F8.0  |
84 +--------+------+
85
86        x        y        j
87 -------- -------- --------
88     5.00     6.00    55.00 
89     2.00     3.00    55.00 
90 EOF
91 if [ $? -ne 0 ] ; then fail ; fi
92
93 pass;