How is && supposed to work in csh?

Jeffery Bacon BACON at MTUS5.BITNET
Sat Oct 21 05:35:21 AEST 1989


(This is also a test to see whether this new netnews server I just put in
blows up or not.)

I have the following chunk of code on a Sun 3 running SOS 4.0.3...

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 idea here is to implement a cheap 'arch' cmd inside my script instead of
having to start another shell (by running 'arch'). But, on SOS 4.0.3 for
68020's, there is no /bin/sun4c. So of course that if comes back false.
What I would expect is that the shell would go on to the next line (i.e.
go look for /bin/sun3). Instead, it only skips the /bin/sun4c cmd and goes
ahead and executes the rest of the line! Is this normal? I thought that
if you use an 'if () cmd' construct, it would take the rest of the line...?
Or is it treating the '&&' as the end-of-line?

Would someone be kind enough to explain? I've RTFM'ed and RTF(C-Shell Field
Guide)'ed; neither were very explicit, and there are no gurus to ask because
I'm supposedly one of them. (We're not unix-literate here.)

Thanks.
-------
Jeffery Bacon
Computing Technology Svcs., Michigan Technological University
bitnet: bacon at mtus5  uucp (alternate): <backbone>!rutgers!clip!anet!bacos



More information about the Comp.unix.questions mailing list