[net.unix] Should shell command errors abandon subsequent commands?

idallen@watmath.UUCP (07/20/84)

Consider the following set of shell (any shell) commands and give me
your opinion on what the best, ideal, most friendly behaviour would be:

   1.  nosuchcommand ; echo "Is this executed?"
   2.  ( nosuchcommand ; cmd ) ; echo "Is this executed?"
   3.  echo `nosuchcommand` "Is this executed?"
   4.  cmd nosuchglob* ; echo "Is this executed?"

Tell me what you think should ideally happen A) in interactive use at a
terminald and B) inside a shell file.  Does it make any difference
whether or not the commands are shell built-ins?  In a shell file,
would it make any difference if the commands were on separate lines?

[ For you CSH fans, try "echo nosuchglob* ; date" and
"/bin/echo nosuchglob* ; date" and see if you like the difference.]
-- 
        -IAN!  (Ian! D. Allen)      University of Waterloo

keesan@bbncca.ARPA (Morris Keesan) (07/20/84)

-------------------------------

Shell command errors should NOT abandon subsequent commands, if the commands
are separated, as in the examples, by semicolons.  Semicolons should behave
exactly like newline.  This should be true regardless of whether the shell
is interactive (from the terminal) or running a script.

The separator ';' means "execute the first command, then execute the second."
The separator '&&' means "execute the first command, and if it succeeds (i.e.
    returns exit status 0) then execute the second."
The separator '||' means "execute the first command, and if it fails (returns
    non-zero exit status) then execute the second."

Given the availability of the && and || separators, there is no reason and no
excuse for the ; to imply any attention to the exit status.
-- 
			    Morris M. Keesan
			    {decvax,linus,ihnp4,wivax,wjh12,ima}!bbncca!keesan
			    keesan @ BBN-UNIX.ARPA

stanwyck@ihuxr.UUCP (Don Stanwyck) (07/26/84)

Response to letter From: idallen@watmath.UUCP
> Consider the following set of shell (any shell) commands and give me
> your opinion on what the best, ideal, most friendly behaviour would be:
>    1.  nosuchcommand ; echo "Is this executed?"
>    2.  ( nosuchcommand ; cmd ) ; echo "Is this executed?"
>    3.  echo `nosuchcommand` "Is this executed?"
>    4.  cmd nosuchglob* ; echo "Is this executed?"
> Tell me what you think should ideally happen A) in interactive use at a
> terminald and B) inside a shell file.  Does it make any difference
> whether or not the commands are shell built-ins?  In a shell file,
> would it make any difference if the commands were on separate lines?

Obviously the author of the above lines expects the echo to be executed.
If [s]he didn't, [s]he would have used || or && instead of the ;. 
-- 
 ________
 (      )					Don Stanwyck
@( o  o )@					312-979-3062
 (  ||  )					Cornet-367-3062
 ( \__/ )					ihnp4!ihuxr!stanwyck
 (______)					Bell Labs @ Naperville, IL