Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.unix.questions Subject: Re: rm delayed? Message-ID: <105049@convex.convex.com> Date: 17 Aug 90 11:44:05 GMT References: Sender: news@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 48 In article bglenden@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]