rm delayed?

Tom Christiansen tchrist at convex.COM
Fri Aug 17 21:44:05 AEST 1990


In article <BGLENDEN.90Aug17013335 at mandrill.cv.nrao.edu> bglenden at mandrill.cv.nrao.edu (Brian Glendenning) writes:
>
>Is it ever possible for a shell script snippet like the following:
>
>touch /tmp/bad.$$
>[...]
># Success
>rm /tmp/bad.$$
>[...]
>if [ -f /tmp/bad.$$]
>then
>	echo failed
>	exit 1
>fi
>
>To falsely report failure? This seems to be happening on our system
>(convex). Is it true that if the rm succeeds it does so immediately,
>or is it possible that some sort of race can be causing a false
>apparent failure? I wouldn't have thought so, but I can't quite see
>where else the script might be going wrong. Thanks!

I've tested this on version 7, 8, 8.1 and 9 of the O/S, and here's what
I've found.  

1) First of all, you need a space between the $$ and the ] or you
   get a "test: ] missing" error.

2) Having fixed that, I never get the 'failed' to print, *BUT* on 
   version 7 and 8 of ConvexOS when put in a shell script like this:

    #!/bin/sh
    touch /tmp/bad.$$
    rm /tmp/bad.$$
    if [ -f /tmp/bad.$$ ]
    then
	echo failed
	exit 1
    fi

    The shell script itself returns an exit status of 1.  This
    is a problem that can really screw up your makefiles.  
    Fortunately, it's fixed by version 8.1, so if this is your
    problem, an upgrade will fix it.

--tom
--
  "UNIX was never designed to keep people from doing stupid things, because 
   that policy would also keep them from doing clever things." [Doug Gwyn]



More information about the Comp.unix.questions mailing list