620836d7b898170ba959b09afa822af22ef139aa
[mmh] / SPECS / build-nmh-cygwin
1 #!/bin/bash
2 #
3 # ==========================================================================
4 # Based on Cygwin generic package build script, customized for nmh.
5 # Relies on nmh VERSION file.
6 #
7 # This script is incompatible with directory names that contain spaces, etc.
8 # To fix that, a whole bunch of shell variables need to be wrapped with "".
9 # ==========================================================================
10 #
11 # Generic package build script
12 #
13 # $Id: generic-build-script,v 1.47 2006/02/01 14:01:14 igor Exp $
14 #
15 # Package maintainers: if the original source is not distributed as a
16 # (possibly compressed) tarball, set the value of ${src_orig_pkg_name},
17 # and redefine the unpack() helper function appropriately.
18 # Also, if the Makefile rule to run the test suite is not "check", change
19 # the definition of ${test_rule} below.
20
21 # find out where the build script is located
22 tdir=`echo "$0" | sed 's%[\\/][^\\/][^\\/]*$%%'`
23 test "x$tdir" = "x$0" && tdir=.
24 scriptdir=`cd $tdir; pwd`
25 # find src directory.
26 # If scriptdir ends in SPECS, then topdir is $scriptdir/..
27 # If scriptdir ends in CYGWIN-PATCHES, then topdir is $scriptdir/../..
28 # Otherwise, we assume that topdir = scriptdir
29 topdir1=`echo ${scriptdir} | sed 's%/SPECS$%%'`
30 topdir2=`echo ${scriptdir} | sed 's%/CYGWIN-PATCHES$%%'`
31 if [ "x$topdir1" != "x$scriptdir" ] ; then # SPECS
32   topdir=`cd ${scriptdir}/..; pwd`
33 else
34   if [ "x$topdir2" != "x$scriptdir" ] ; then # CYGWIN-PATCHES
35     topdir=`cd ${scriptdir}/../..; pwd`
36   else
37     topdir=`cd ${scriptdir}; pwd`
38   fi
39 fi
40
41 # Change from generic-build-script:  save pwd for later use.
42 pwd=`pwd`
43
44 # Change from generic-build-script:  base version on contents of
45 # VERSION instead of script name.  Looks first for VERSION in
46 # current directory, then in $topdir.
47 test -e VERSION  &&  version=VERSION  ||  version="${topdir}/VERSION"
48 if ! test -e "${version}"; then
49   echo "$0: need VERSION file"
50   exit 1
51 fi
52
53 tscriptname=nmh-`cat "${version}"`
54 # Change from generic-build-script: allow + in addition to - between
55 # VER and REL, e.g., 1.5+dev.
56 export PKG=`echo $tscriptname | sed -e 's/\-[^\-]*[+-][^+-]*$//'`
57 export VER=`echo $tscriptname | sed -e "s/${PKG}\-//" -e 's/[+-][^+-]*$//'`
58 export REL=`echo $tscriptname | sed -e "s/${PKG}\-${VER}\([+-]\)/\1/"`
59 # BASEPKG refers to the upstream base package
60 # SHORTPKG refers to the Cygwin package
61 # Normally, these are identical, but if the Cygwin package name is different
62 # from the upstream package name, you will want to redefine BASEPKG.
63 # Example: For Apache 2, BASEPKG=httpd-2.x.xx but SHORTPKG=apache2-2.x.xx
64 #
65 # Change from generic-build-script: added DISABLE_SETGID_MAIL=1 so that
66 # install will not try to chgrp/chmod bin/inc.
67 export DISABLE_SETGID_MAIL=1
68 # Change from generic-build-script: added -${REL} to BASEPKG.
69 export BASEPKG=${PKG}-${VER}${REL}
70 export SHORTPKG=${PKG}-${VER}
71 export FULLPKG=${SHORTPKG}${REL}
72
73 # determine correct decompression option and tarball filename
74 export src_orig_pkg_name=
75 if [ -e "${src_orig_pkg_name}" ] ; then
76   export opt_decomp=? # Make sure tar punts if unpack() is not redefined
77 elif [ -e ${BASEPKG}.tar.bz2 ] ; then
78   export opt_decomp=j
79   export src_orig_pkg_name=${BASEPKG}.tar.bz2
80 elif [ -e ${BASEPKG}.tar.gz ] ; then
81   export opt_decomp=z
82   export src_orig_pkg_name=${BASEPKG}.tar.gz
83 elif [ -e ${BASEPKG}.tgz ] ; then
84   export opt_decomp=z
85   export src_orig_pkg_name=${BASEPKG}.tgz
86 elif [ -e ${BASEPKG}.tar ] ; then
87   export opt_decomp=
88   export src_orig_pkg_name=${BASEPKG}.tar
89 else
90   # Change from generic-build-script:  build the tarball if it doesn't exist.
91   (cd "${topdir}" && make dist)
92   if [ -e "${topdir}/${BASEPKG}.tar.gz" ] ; then
93     export opt_decomp=z
94     export src_orig_pkg_name=${BASEPKG}.tar.gz
95   else
96     echo "Cannot find PKG:${PKG} VER:${VER} REL:${REL}.  Rename $0 to"
97     echo "something more appropriate, and try again."
98     exit 1
99   fi
100 fi
101
102 export src_orig_pkg=${topdir}/${src_orig_pkg_name}
103
104 # determine correct names for generated files
105 export src_pkg_name=${FULLPKG}-src.tar.bz2
106 export src_patch_name=${FULLPKG}.patch
107 export bin_pkg_name=${FULLPKG}.tar.bz2
108 export log_pkg_name=${FULLPKG}-BUILDLOGS.tar.bz2
109
110 export configurelogname=${FULLPKG}-CONFIGURE.LOG
111 export makelogname=${FULLPKG}-MAKE.LOG
112 export checklogname=${FULLPKG}-CHECK.LOG
113 export installlogname=${FULLPKG}-INSTALL.LOG
114
115 # Change from generic-build-script: put src_pkg and bin_pkg in current
116 # directory.
117 export src_pkg=${pwd}/${src_pkg_name}
118 export src_patch="${topdir}"/${src_patch_name}
119 export bin_pkg=${pwd}/${bin_pkg_name}
120 export srcdir="${topdir}"/${BASEPKG}
121 export objdir=${srcdir}/.build
122 export instdir=${srcdir}/.inst
123 export srcinstdir=${srcdir}/.sinst
124 export buildlogdir=${srcdir}/.buildlogs
125 export configurelogfile=${srcinstdir}/${configurelogname}
126 export makelogfile=${srcinstdir}/${makelogname}
127 export checklogfile=${srcinstdir}/${checklogname}
128 export installlogfile=${srcinstdir}/${installlogname}
129
130 prefix=/usr
131 sysconfdir=/etc
132 localstatedir=/var
133 if [ -z "$MY_CFLAGS" ]; then
134   MY_CFLAGS="-O2"
135 fi
136 if [ -z "$MY_LDFLAGS" ]; then
137   MY_LDFLAGS=
138 fi
139
140 # Change from generic-build-script: removed ChangeLog because the nmh
141 # Makefile installs it.
142 export install_docs="\
143         ABOUT-NLS \
144         ANNOUNCE \
145         AUTHORS \
146         BUG-REPORTS \
147         CHANGES \
148         CONTRIBUTORS \
149         COPYING \
150         COPYRIGHT \
151         CREDITS \
152         CHANGELOG \
153         FAQ \
154         HOW-TO-CONTRIBUTE \
155         INSTALL \
156         KNOWNBUG \
157         LEGAL \
158         LICENSE \
159         NEWS \
160         NOTES \
161         PROGLIST \
162         README \
163         RELEASE_NOTES \
164         THANKS \
165         TODO \
166         USAGE \
167 "
168 export install_docs="`for i in ${install_docs}; do echo $i; done | sort -u`"
169 export test_rule=check
170 if [ -z "$SIG" ]; then
171   export SIG=0  # set to 1 to turn on signing by default
172 fi
173 # Sort in POSIX order.
174 export LC_ALL=C
175
176 # helper functions
177
178 # Provide help.
179 help() {
180 cat <<EOF
181 This is the cygwin packaging script for ${FULLPKG}.
182 Usage: $0 [<option>...] <action>...
183 Options are:
184     help, --help        Print this message
185     version, --version  Print the version message
186     with_logs, --logs   Create logs of remaining steps
187 Actions are:
188     prep                Unpack and patch into ${srcdir}
189     mkdirs              Make hidden directories needed during build
190     conf, configure     Configure the package (./configure)
191     reconf              Rerun configure
192     build, make         Build the package (make)
193     check, test         Run the testsuite (make ${test_rule})
194     clean               Remove built files (make clean)
195     install             Install package to staging area (make install)
196     list                List package contents
197     depend              List package dependencies
198     strip               Strip package executables
199     pkg, package        Prepare the binary package ${bin_pkg_name}
200     mkpatch             Prepare the patch file ${src_patch_name}
201     acceptpatch         Copy patch file ${src_patch_name} to ${topdir}
202     spkg, src-package   Prepare the source package ${src_pkg_name}
203     finish              Remove source directory ${srcdir}
204     checksig            Validate GPG signatures (requires gpg)
205     first               Full run for spkg (mkdirs, spkg, finish)
206     almostall           Full run for bin pkg, except for finish
207     all                 Full run for bin pkg
208 EOF
209 }
210
211 # Provide version of generic-build-script modified to make this script.
212 version() {
213     vers=`echo '$Revision: 1.47 $' | sed -e 's/Revision: //' -e 's/ *\\$//g'`
214     echo "$0 based on generic-build-script $vers"
215 }
216
217 # Unpacks the original package source archive into ./${BASEPKG}/.
218 # Change this if the original package was not tarred
219 # or if it doesn't unpack to a correct directory.
220 unpack() {
221   tar xv${opt_decomp}f "$1"
222 }
223
224 # Make the hidden directories used by this script.
225 mkdirs() {
226   (cd ${topdir} && \
227   rm -fr ${objdir} ${instdir} ${srcinstdir} && \
228   mkdir -p ${objdir} && \
229   mkdir -p ${instdir} && \
230   mkdir -p ${srcinstdir} )
231 }
232 mkdirs_log() {
233   (cd ${topdir} && \
234   mkdirs "$@" && \
235   rm -fr ${buildlogdir} && \
236   mkdir -p ${buildlogdir} )
237 }
238
239 # Unpack the original tarball, and get everything set up for this script.
240 prep() {
241   (cd ${topdir} && \
242   unpack ${src_orig_pkg} && \
243   cd ${topdir} && \
244   if [ -f ${src_patch} ] ; then \
245     patch -Z -p0 < ${src_patch} ;\
246   fi && \
247   mkdirs )
248 }
249 prep_log() {
250   prep "$@" && \
251   mkdirs_log && \
252   if [ -f ${topdir}/${log_pkg_name} ] ; then \
253     # Change from generic-build-script:  do the following in subshell
254     # so that cd isn't permanent.
255     (cd ${buildlogdir} && \
256     tar xvjf "${topdir}"/${log_pkg_name})
257   fi
258 }
259
260 # Configure the package.
261 conf() {
262   (cd ${objdir} && \
263   CFLAGS="${MY_CFLAGS}" LDFLAGS="${MY_LDFLAGS}" \
264   ${srcdir}/configure \
265   --srcdir=${srcdir} --prefix="${prefix}" \
266   --exec-prefix='${prefix}' --sysconfdir="${sysconfdir}" \
267   --libdir='${prefix}/lib' --includedir='${prefix}/include' \
268   --mandir='${prefix}/share/man' --infodir='${prefix}/share/info' \
269   --libexecdir='${sbindir}' --localstatedir="${localstatedir}" \
270   --datadir='${prefix}/share' )
271 }
272 conf_log() {
273   conf "$@" 2>&1 | tee ${configurelogfile}
274   return ${PIPESTATUS[0]}
275 }
276
277 # Rerun configure to pick up changes in the environment.
278 reconf() {
279   (cd ${topdir} && \
280   rm -fr ${objdir} && \
281   mkdir -p ${objdir} && \
282   conf )
283 }
284 reconf_log() {
285   reconf "$@" 2>&1 | tee ${configurelogfile}
286   return ${PIPESTATUS[0]}
287 }
288
289 # Run make.
290 build() {
291   (cd ${objdir} && \
292   make CFLAGS="${MY_CFLAGS}" )
293 }
294 build_log() {
295   build "$@" 2>&1 | tee ${makelogfile}
296   return ${PIPESTATUS[0]}
297 }
298
299 # Run the package testsuite.
300 check() {
301   (cd ${objdir} && \
302   make -k ${test_rule} )
303 }
304 check_log() {
305   check "$@" 2>&1 | tee ${checklogfile}
306   return ${PIPESTATUS[0]}
307 }
308
309 # Remove files created by configure and make.
310 clean() {
311   (cd ${objdir} && \
312   make clean )
313 }
314
315 # Install the package, with DESTDIR set to '.inst'.
316 # Change from generic-build-script:  added ":;" after "find ... | gzip"
317 # because it returns non-zero status.
318 install() {
319   (cd ${objdir} && \
320   rm -fr ${instdir}/* && \
321   make install DESTDIR=${instdir} && \
322   for f in ${prefix}/share/info/dir ${prefix}/info/dir ; do \
323     if [ -f ${instdir}${f} ] ; then \
324       rm -f ${instdir}${f} ; \
325     fi ;\
326   done &&\
327   for d in ${prefix}/share/doc/${SHORTPKG} ${prefix}/share/doc/Cygwin ; do \
328     if [ ! -d ${instdir}${d} ] ; then \
329       mkdir -p ${instdir}${d} ;\
330     fi ;\
331   done &&\
332   if [ -d ${instdir}${prefix}/share/info ] ; then \
333     find ${instdir}${prefix}/share/info -name "*.info" | xargs -r gzip -q ; \
334   fi && \
335   if [ -d ${instdir}${prefix}/share/man ] ; then \
336     find ${instdir}${prefix}/share/man -name "*.1" -o -name "*.3" -o \
337       -name "*.3x" -o -name "*.3pm" -o -name "*.5" -o -name "*.6" -o \
338       -name "*.7" -o -name "*.8" | xargs -r gzip -q ; :; \
339   fi && \
340   templist="" && \
341   for fp in ${install_docs} ; do \
342     case "$fp" in \
343       */) templist="$templist `find ${srcdir}/$fp -type f`" ;;
344       *)  for f in ${srcdir}/$fp ; do \
345             if [ -f $f ] ; then \
346               templist="$templist $f"; \
347             fi ; \
348           done ;; \
349     esac ; \
350   done && \
351   if [ ! "x$templist" = "x" ]; then \
352     /usr/bin/install -m 644 $templist \
353          ${instdir}${prefix}/share/doc/${SHORTPKG} ; \
354   fi && \
355   if [ -f ${srcdir}/CYGWIN-PATCHES/${PKG}.README ]; then \
356     /usr/bin/install -m 644 ${srcdir}/CYGWIN-PATCHES/${PKG}.README \
357       ${instdir}${prefix}/share/doc/Cygwin/${SHORTPKG}.README ; \
358   elif [ -f ${srcdir}/CYGWIN-PATCHES/README ] ; then \
359     /usr/bin/install -m 644 ${srcdir}/CYGWIN-PATCHES/README \
360       ${instdir}${prefix}/share/doc/Cygwin/${SHORTPKG}.README ; \
361   fi && \
362   if [ -f ${srcdir}/CYGWIN-PATCHES/${PKG}.sh ] ; then \
363     if [ ! -d ${instdir}${sysconfdir}/postinstall ]; then \
364       mkdir -p ${instdir}${sysconfdir}/postinstall ; \
365     fi && \
366     /usr/bin/install -m 755 ${srcdir}/CYGWIN-PATCHES/${PKG}.sh \
367       ${instdir}${sysconfdir}/postinstall/${PKG}.sh ; \
368   elif [ -f ${srcdir}/CYGWIN-PATCHES/postinstall.sh ] ; then \
369     if [ ! -d ${instdir}${sysconfdir}/postinstall ]; then \
370       mkdir -p ${instdir}${sysconfdir}/postinstall ; \
371     fi && \
372     /usr/bin/install -m 755 ${srcdir}/CYGWIN-PATCHES/postinstall.sh \
373       ${instdir}${sysconfdir}/postinstall/${PKG}.sh ; \
374   fi && \
375   if [ -f ${srcdir}/CYGWIN-PATCHES/preremove.sh ] ; then \
376     if [ ! -d ${instdir}${sysconfdir}/preremove ]; then \
377       mkdir -p ${instdir}${sysconfdir}/preremove ; \
378     fi && \
379     /usr/bin/install -m 755 ${srcdir}/CYGWIN-PATCHES/preremove.sh \
380       ${instdir}${sysconfdir}/preremove/${PKG}.sh ; \
381   fi &&
382   if [ -f ${srcdir}/CYGWIN-PATCHES/manifest.lst ] ; then
383     if [ ! -d ${instdir}${sysconfdir}/preremove ]; then
384       mkdir -p ${instdir}${sysconfdir}/preremove ;
385     fi &&
386     /usr/bin/install -m 644 ${srcdir}/CYGWIN-PATCHES/manifest.lst \
387       ${instdir}${sysconfdir}/preremove/${PKG}-manifest.lst ;
388   fi )
389 }
390 install_log() {
391   install "$@" 2>&1 | tee ${installlogfile}
392   return ${PIPESTATUS[0]}
393 }
394
395 # Strip all binaries.
396 strip() {
397   (cd ${instdir} && \
398   find . -name "*.dll" -or -name "*.exe" | xargs -r strip 2>&1 ; \
399   true )
400 }
401
402 # List all non-hidden files that belong to the package.
403 list() {
404   (cd ${instdir} && \
405   find . -name "*" ! -type d | sed 's%^\.%  %' | sort ; \
406   true )
407 }
408
409 # List the static .dll dependencies of the package.  This does not pick up
410 # dynamic dependencies (whether or not libtool was used), nor does it pick
411 # up program dependencies, such as system() depending on /bin/sh.
412 depend() {
413   (cd ${instdir} && \
414   find ${instdir} -name "*.exe" -o -name "*.dll" | xargs -r cygcheck | \
415   sed -ne '/^  [^ ]/ s,\\,/,gp' | sort -bu | \
416   xargs -r -n1 cygpath -u | xargs -r cygcheck -f | sed 's%^%  %' | sort -u ; \
417   true )
418 }
419
420 # Build the binary package tarball.
421 pkg() {
422   (cd ${instdir} && \
423   tar cvjf ${bin_pkg} * )
424 }
425
426 # Compare the original tarball against cygwin modifications.
427 mkpatch() {
428   (cd ${srcdir} && \
429   find . -name "autom4te.cache" | xargs -r rm -rf ; \
430   unpack ${src_orig_pkg} && \
431   mv ${BASEPKG} ../${BASEPKG}-orig && \
432   cd ${topdir} && \
433   diff -urN -x '.build' -x '.inst' -x '.sinst' -x '.buildlogs' \
434     ${BASEPKG}-orig ${BASEPKG} > \
435     ${srcinstdir}/${src_patch_name} ; \
436   rm -rf ${BASEPKG}-orig )
437 }
438
439 # Note: maintainer-only functionality
440 acceptpatch() {
441   cp --backup=numbered ${srcinstdir}/${src_patch_name} ${topdir}
442 }
443
444 # Build the source tarball.
445 # Change from generic-build-script:  added VERSION file.
446 spkg() {
447   (mkpatch && \
448   if [ "${SIG}" -eq 1 ] ; then \
449     name=${srcinstdir}/${src_patch_name} text="PATCH" sigfile ; \
450   fi && \
451   cp ${src_orig_pkg} ${srcinstdir}/${src_orig_pkg_name} && \
452   if [ -e ${src_orig_pkg}.sig ] ; then \
453     cp ${src_orig_pkg}.sig ${srcinstdir}/ ; \
454   fi && \
455   cp $0 ${srcinstdir}/`basename $0` && \
456   name=$0 text="SCRIPT" sigfile && \
457   if [ "${SIG}" -eq 1 ] ; then \
458     cp $0.sig ${srcinstdir}/ ; \
459   fi && \
460   cp "${version}" "${srcinstdir}" && \
461   cd ${srcinstdir} && \
462   tar cvjf ${src_pkg} * )
463 }
464 spkg_log() {
465   spkg "$@" && \
466   (cd ${srcinstdir} && \
467   if [ -e ${configurelogname} -o -e ${makelogname} -o \
468        -e ${checklogname} -o -e ${installlogname} ]; then
469     tar --ignore-failed-read -cvjf ${log_pkg_name} \
470       ${configurelogname} ${makelogname} ${checklogname} ${installlogname} && \
471     rm -f \
472       ${configurelogname} ${makelogname} ${checklogname} ${installlogname} ; \
473   fi && \
474   tar uvjf ${src_pkg} * )
475 }
476
477 # Clean up everything.
478 finish() {
479   rm -rf ${srcdir}
480 }
481
482 # Generate GPG signatures.
483 sigfile() {
484   if [ \( "${SIG}" -eq 1 \) -a \( -e $name \) -a \( \( ! -e $name.sig \) -o \( $name -nt $name.sig \) \) ]; then \
485     if [ -x /usr/bin/gpg ]; then \
486       echo "$text signature need to be updated"; \
487       rm -f $name.sig; \
488       /usr/bin/gpg --detach-sign $name; \
489     else \
490       echo "You need the gnupg package installed in order to make signatures."; \
491     fi; \
492   fi
493 }
494
495 # Validate GPG signatures.
496 checksig() {
497   if [ -x /usr/bin/gpg ]; then \
498     if [ -e ${src_orig_pkg}.sig ]; then \
499       echo "ORIGINAL PACKAGE signature follows:"; \
500       /usr/bin/gpg --verify ${src_orig_pkg}.sig ${src_orig_pkg}; \
501     else \
502       echo "ORIGINAL PACKAGE signature missing."; \
503     fi; \
504     if [ -e $0.sig ]; then \
505       echo "SCRIPT signature follows:"; \
506       /usr/bin/gpg --verify $0.sig $0; \
507     else \
508       echo "SCRIPT signature missing."; \
509     fi; \
510     if [ -e ${src_patch}.sig ]; then \
511       echo "PATCH signature follows:"; \
512       /usr/bin/gpg --verify ${src_patch}.sig ${src_patch}; \
513     else \
514       echo "PATCH signature missing."; \
515     fi; \
516   else
517     echo "You need the gnupg package installed in order to check signatures." ; \
518   fi
519 }
520
521 f_mkdirs=mkdirs
522 f_prep=prep
523 f_conf=conf
524 f_reconf=conf
525 f_build=build
526 f_check=check
527 f_install=install
528 f_spkg=spkg
529
530 enablelogging() {
531   f_mkdirs=mkdirs_log && \
532   f_prep=prep_log && \
533   f_conf=conf_log && \
534   f_reconf=reconf_log && \
535   f_build=build_log && \
536   f_check=check_log && \
537   f_install=install_log && \
538   f_spkg=spkg_log
539 }
540
541 while test -n "$1" ; do
542   case $1 in
543     help|--help)        help ; STATUS=$? ;;
544     version|--version)  version ; STATUS=$? ;;
545     with_logs|--logs)   enablelogging ; STATUS=$? ;;
546     prep)               $f_prep ; STATUS=$? ;;
547     mkdirs)             $f_mkdirs ; STATUS=$? ;;
548     conf)               $f_conf ; STATUS=$? ;;
549     configure)          $f_conf ; STATUS=$? ;;
550     reconf)             $f_reconf ; STATUS=$? ;;
551     build)              $f_build ; STATUS=$? ;;
552     make)               $f_build ; STATUS=$? ;;
553     check)              $f_check ; STATUS=$? ;;
554     test)               $f_check ; STATUS=$? ;;
555     clean)              $f_clean ; STATUS=$? ;;
556     install)            $f_install ; STATUS=$? ;;
557     list)               list ; STATUS=$? ;;
558     depend)             depend ; STATUS=$? ;;
559     strip)              strip ; STATUS=$? ;;
560     package)            pkg ; STATUS=$? ;;
561     pkg)                pkg ; STATUS=$? ;;
562     mkpatch)            mkpatch ; STATUS=$? ;;
563     acceptpatch)        acceptpatch ; STATUS=$? ;;
564     src-package)        $f_spkg ; STATUS=$? ;;
565     spkg)               $f_spkg ; STATUS=$? ;;
566     finish)             finish ; STATUS=$? ;;
567     checksig)           checksig ; STATUS=$? ;;
568     first)              $f_mkdirs && $f_spkg && finish ; STATUS=$? ;;
569     almostall)          checksig && $f_prep && $f_conf && $f_build && \
570                         $f_install && strip && pkg && $f_spkg ; STATUS=$? ;;
571     all)                checksig && $f_prep && $f_conf && $f_build && \
572                         $f_install && strip && pkg && $f_spkg && finish ; \
573                         STATUS=$? ;;
574     *) echo "Error: bad arguments" ; exit 1 ;;
575   esac
576   ( exit ${STATUS} ) || exit ${STATUS}
577   shift
578 done