Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!uhccux!munnari.oz.au!cs.mu.oz.au!ok From: ok@cs.mu.oz.au (Richard O'Keefe) Newsgroups: comp.unix.questions Subject: Re: How is && supposed to work in csh? Message-ID: <2487@munnari.oz.au> Date: 21 Oct 89 09:45:12 GMT References: <89293.143521BACON@MTUS5.BITNET> Sender: news@cs.mu.oz.au Lines: 35 In article <89293.143521BACON@MTUS5.BITNET>, BACON@MTUS5.BITNET (Jeffery Bacon) writes: > if ( -f /bin/sun4 ) /bin/sun4 && set arch=sun4 && goto gotarch > if ( -f /bin/sun4c ) /bin/sun4c && set arch=sun4 && goto gotarch > if ( -f /bin/sun3 ) /bin/sun3 && set arch=sun3 && goto gotarch > if ( -f /bin/sun3x ) /bin/sun3x && set arch=sun3 && goto gotarch > gotarch: The csh(1) manual page says about if (expr) command that "command must be a simple command, not a pipeline, a command list, or a parenthesized command list." One of the possible cases for a pipeline is a sequence of commands separated by "&&". A simpler scheme would be to do if (-f /bin/sun4 && { /bin/sun4 }) then set arch=sun4 else if (-f /bin/sun4c && { /bin/sun4c }) then set arch=sun4 else if (-f /bin/sun3 && { /bin/sun3 }) then set arch=sun3 else if (-f /bin/sun3c && { /bin/sun3c }) then set arch=sun3 else echo "Unable to determine architecture type" exit 1 endif I find that it is generally better to write scripts using the Bourne shell (sh) than the C shell (csh): the sh language has rather fewer gotchas. It is also easier to do some things. For example, I would really like the error message to come out on stderr rather than stdout. In sh it's easy: echo "Unable to determine architecture type" >&2 Given that you are going to try running up to four programs /bin/sun{3,4}{,c} anyway, it seems odd to boggle at using the /bin/arch script to do it.