From: euabem@eua.ericsson.se (Bertil Engelholm)
Newsgroups: comp.unix.questions
Subject: rm Question (was : C-shell Question
Date: 9 Nov 92 08:24:04 GMT
Reply-To: euabem@eua.ericsson.se
Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden

Hi, again

Thanks again for all your answers.
Due to my bad english in my two last articles it seems like I mislead most 
of you out there, sorry about that :(.

But one answer I got indicates that it seems to be something 
wrong with the command 'rm'. So it is not really a C-shell or
rsh problem (or my mistake :) ).
 
I share this answer with you and asks if someone can answer the question 
why the command 'rm' don't work as expected. (is it a bug or a feature :) ? )

/Bertil

From bortz@cnam.cnam.fr Thu Nov  5 17:44:11 1992
Date: Thu, 5 Nov 1992 17:43:56 +0100
From: Stephane Bortzmeyer <bortz@cnam.cnam.fr>
To: euabem@eua.ericsson.se
Cc: bortz@cnam.cnam.fr, letondal@cnam.cnam.fr, wandel@cnam.cnam.fr
Subject: Re: C-Shell question
Content-Length: 1355

A few minutes after I replied, I followed my own advice and wrote the following script:

#!/bin/csh

/bin/rm $1 

if ( $status != 0 ) then
    echo 'My damned script failed'
    exit 1
endif

echo 'Yeah, I did it'
exit 0

That's really amazing, but when I run it interactively, it works in both cases (file exists or not) and when it's run under 'rsh', the $status after rm is always 0!!! (I can see that because of the message.)
I simply don't understand. I'm working on it (Cc: people can help me, do they?).

This script has the correct behaviour if I replace 'rm' by another command (like 'mv'). Therefore, I suspect a problem with 'rm' which apparently doesn't set $status if not run from a tty.

Stephane Bortzmeyer           Conservatoire National des Arts et Metiers	
bortzmeyer@cnam.cnam.fr       Laboratoire d'Informatique
                              292, rue Saint-Martin			
tel: +33 (1) 40 27 27 31      75141 Paris Cedex 03
fax: +33 (1) 40 27 27 72      France	

"C'est la nuit qu'il est beau de croire a la lumiere." E. Rostand

=================================================================

From bortz@cnam.cnam.fr Fri Nov  6 09:04:51 1992
To: comp-unix-questions@ucbvax.berkeley.edu
Cc: bortz@cnam.cnam.fr, letondal@cnam.cnam.fr, wandel@cnam.cnam.fr,
        euabem@eua.ericsson.se
Newsgroups: comp.unix.questions
Distribution: world
From: bortzmeyer@cnam.cnam.fr (Stephane Bortzmeyer)
Organization: cnam
Subject: Re: C-Shell question
Date: Fri, 06 Nov 92 09:04:43 +0100
X-Mts: smtp
Content-Length: 1365

In article <1992Nov4.080338.9458@eua.ericsson.se>,
euabem@eua.ericsson.se (Bertil Engelholm) writes:
[problem with 'rm' under 'rsh']
> All the answers is saying that the exit-code stored in $status is the result
> code of rsh. But how can that happen ? How can the result code of rsh be stored
> in the $status variable before rsh has executed all of the script ?

There is something funny with 'rm'. If I write the following script:

#!/bin/csh
/bin/mv $1 trash
if ( $status != 0 ) then
    echo 'My damned script failed'
    exit 1
endif
echo 'Yeah, I did it'
exit 0

and execute it when the file given as $1 doesn't exist, everything is
fine. I get the 
message 'My damned script failed' when I launch it interactively or threw 'rsh'.

If I replace 'mv' with 'rm', I ALWAYS GOT THE MESSAGE 'Yeah, I did it'
wether $1 exists 
or not, as soon as the script is used by 'rsh'! 

Other commands behave as 'mv'. Now, there's clearly something wrong
with 'rm'. Is it 
possible it doesn't set $status when run without a tty???

Stephane Bortzmeyer           Conservatoire National des Arts et Metiers	
bortzmeyer@cnam.cnam.fr       Laboratoire d'Informatique
                              292, rue Saint-Martin			
tel: +33 (1) 40 27 27 31      75141 Paris Cedex 03
fax: +33 (1) 40 27 27 72      France	

"C'est la nuit qu'il est beau de croire a la lumiere." E. Rostand