[m-dev.] for review: bootchecking the extras

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Nov 22 14:05:20 AEDT 2000


On 22-Nov-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> On 21-Nov-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > It might be a good idea to use `trap' to ensure that the
> > extras/Mmake.params file gets restored if you interrupt a bootcheck.
> 
> It may be a good idea, but hard to do reliably

How about like this?
(+ in left column shows the lines I've added)

	if test -f Mmake.params; then
+		trap 'mv Mmake.params.$$ Mmake.params; exit 1' 1 2 3 13 15
		mv Mmake.params Mmake.params.$$
+	else
+		trap 'rm -f Mmake.params; exit 1' 1 2 3 13 15
	fi

	...
	... code to create Mmake.params and run the tests ...
	...

	if test -f Mmake.params.$$; then
		mv Mmake.params.$$ Mmake.params
	else
		/bin/rm Mmake.params
	fi
+	# remove signal handler
+	trap 1 2 3 13 15

I suppose that might do the wrong thing in the unlikely case that
there happened to be a file named Mmake.params.$$ lying around
already.  If you want to be really safe you could add the following
code at the start:

	# Paranoid check to make sure there's no junk lying
	# around that might confuse us later
	if test -f Mmake.params.$$; then
		echo "$0: please remove the Mmake.params.$$ file"
		exit 1
	fi

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list