Survey on use of ";" "&&" "||" to separate shell commands.

idallen at watmath.UUCP idallen at watmath.UUCP
Tue Dec 4 17:13:30 AEST 1984


1) How often do you use "&&" to separate commands to a shell,
   and under what circumstances?

2) How often do you use "||" to separate commands, and under what circumstances?
   2a) Do you use it to check for *just* the non-zero exit status of the
       command on the left?
   2b) Do you use it to check for all errors in the command on
       the left, including those caused by the shell or by signals to
       the command?
   2c) Other thoughts on the matter...

3) How often do you use "a ; b ; c" when you really mean "a && b && c" ?
   That is, how often do you type in a chain of two or more commands where
   the action of the second and later commands is dependent on the
   successful (zero-return) of the first, but where you don't use the
   conditional operator "&&"?  Why don't you like to use "&&"?

4) How often do you explicitly test the exit code of a command for
   a specific value or range of values?  (For example, do you ever
   test for GREP exiting with 1 but not 2 or 2 but not 1?)

5) Did you know that you can't tell an exit code of 1 from "Command
   not found" because the shell fakes an exit code of 1 if it can't
   find a command?  Do you care?

6) In a command chain "a ; b ; c" do you ever want B and C to be
   abandoned because of some error or happening to A?  Under what
   conditions should this abandoning happen?  (Possible answers:
    * Never - B and C should execute no matter what happens to A
    * If A terminates because of the following signals: X,Y,Z
    * If A never gets started because it's not executable ("Command not
      found") or because of some other shell-detected error such as "No
      match", "too many processes", or "arglist too long"
    * None of the above)

Answers by mail, please, to idallen at watmath.  WATMATH talks to ihnp4,
decvax, utzoo, linus, clyde, allegra.  I will summarize and post.



More information about the Comp.unix.wizards mailing list