Ensure the awk passed in variables are quoted as they
[xfstests-dev.git] / new
1 #! /bin/sh
2 #
3 # Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
4
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of version 2 of the GNU General Public License as
7 # published by the Free Software Foundation.
8
9 # This program is distributed in the hope that it would be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 # Further, this software is distributed without any warranty that it is
14 # free of the rightful claim of any third person regarding infringement
15 # or the like.  Any license provided herein, whether implied or
16 # otherwise, applies only to this software file.  Patent licenses, if
17 # any, provided herein do not apply to combinations of this program with
18 # other software, or any other product whatsoever.
19
20 # You should have received a copy of the GNU General Public License along
21 # with this program; if not, write the Free Software Foundation, Inc., 59
22 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
23
24 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
25 # Mountain View, CA  94043, or:
26
27 # http://www.sgi.com 
28
29 # For further information regarding this notice, see: 
30
31 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #
33 #
34 # Make a new test
35 #
36 # $Header: /build2/depot/linux/pcp/dev/qa/RCS/new,v 2.22 1999/10/06 19:16:53 kenmcd Exp $
37 #
38
39 # generic initialization
40 iam=new
41 . ./common.rc
42
43 trap "rm -f /tmp/$$.; exit" 0 1 2 3 15
44
45 _cleanup()
46 {
47     :
48 }
49
50 if [ ! -f group ]
51 then
52     echo "Creating the group index ..."
53     cat <<'End-of-File' >group
54 # QA groups control
55 #
56 # $Id: new,v 2.22 1999/10/06 19:16:53 kenmcd Exp $
57 #
58 # define groups and default group owners
59 # do not start group name with a digit
60 #
61
62 # catch-all
63 #
64 other           some-user-login
65
66 # test-group association ... one line per test
67 #
68 End-of-File
69 fi
70
71 if [ ! -w group ]
72 then
73     chmod u+w group
74     echo "Warning: making the index file \"group\" writeable"
75 fi
76
77 if make
78 then
79     :
80 else
81     echo "Warning: make failed -- some tests may be missing"
82 fi
83
84 last=`grep '^[0-9][0-9]* ' group | sort | tail -1 | sed -e 's/[         ].*//'`
85 # get rid of leading 0s as can be interpreted as octal
86 last=`echo $last | sed 's/^0*//'`
87 id=`$AWK_PROG </dev/null 'BEGIN{printf "%03d\n",'$last'+1}'`
88 echo "Next test is $id"
89
90 if [ -f $id ]
91 then
92     echo "Error: test $id already exists!"
93     _cleanup
94     exit 1
95 fi
96
97 echo -n "Creating skeletal script for you to edit ..."
98
99 cat <<End-of-File | sed -e '/rcsId/s//Id: 1.1 /' >$id
100 #! /bin/sh
101 # XFS QA Test No. $id
102 # \$rcsId\$
103 #
104 # what am I here for?
105 #
106 #-----------------------------------------------------------------------
107 # Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
108
109 # This program is free software; you can redistribute it and/or modify it
110 # under the terms of version 2 of the GNU General Public License as
111 # published by the Free Software Foundation.
112
113 # This program is distributed in the hope that it would be useful, but
114 # WITHOUT ANY WARRANTY; without even the implied warranty of
115 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
116
117 # Further, this software is distributed without any warranty that it is
118 # free of the rightful claim of any third person regarding infringement
119 # or the like.  Any license provided herein, whether implied or
120 # otherwise, applies only to this software file.  Patent licenses, if
121 # any, provided herein do not apply to combinations of this program with
122 # other software, or any other product whatsoever.
123
124 # You should have received a copy of the GNU General Public License along
125 # with this program; if not, write the Free Software Foundation, Inc., 59
126 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
127
128 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
129 # Mountain View, CA  94043, or:
130
131 # http://www.sgi.com 
132
133 # For further information regarding this notice, see: 
134
135 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
136 #-----------------------------------------------------------------------
137 #
138 # creator
139 owner=$USER@`_get_fqdn`
140
141 seq=\`basename \$0\`
142 echo "QA output created by \$seq"
143
144 here=\`pwd\`
145 tmp=/tmp/\$\$
146 status=1        # failure is the default!
147 trap "rm -f \$tmp.*; exit \\\$status" 0 1 2 3 15
148
149 # get standard environment, filters and checks
150 . ./common.rc
151 . ./common.filter
152
153 # real QA test starts here
154
155 # if error
156 exit
157
158 # optional stuff if your test has verbose output to help resolve problems
159 #echo
160 #echo "If failure, check \$seq.full (this) and \$seq.full.ok (reference)"
161
162 # success, all done
163 status=0
164 exit
165 End-of-File
166
167 sleep 2         # latency to read messages to this point
168 echo ""
169
170 chmod 755 $id
171 ${EDITOR-vi} $id
172
173 if [ $# -eq 0 ]
174 then
175     while true
176     do
177         echo -n "Add to group(s) [other] (? for list): "
178         read ans
179         [ -z "$ans" ] && ans=other
180         if [ "X$ans" = "X?" ]
181         then
182             $AWK_PROG <group '
183 BEGIN           { text = "# ???" }
184 /^[a-zA-z]/     { printf "%-16.16s %s\n",$1,text; text = "# ???"; next }
185 NF < 2          { next }
186                 { text = $0 }' \
187             | sort
188         else
189             break
190         fi
191     done
192 else
193     # expert mode, groups are on the command line
194     #
195     for g in $*
196     do
197         if grep "^$g[   ]" group >/dev/null
198         then
199             :
200         else
201             echo "Warning: group \"$g\" not defined in ./group"
202         fi
203     done
204     ans="$*"
205 fi
206
207 echo -n "Adding $id to group index ..."
208 echo "$id $ans" >>group
209 echo " done."
210
211 exit 0