Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!noao!ncar!mephisto!rutgers!njin!uupsi!sunic!ericom!eua.ericsson.se!erix.ericsson.se!per From: per@erix.ericsson.se (Per Hedeland) Newsgroups: comp.unix.shell Subject: Re: Help needed with conditional statement for alias in csh Message-ID: <1990Sep18.223605.29379@eua.ericsson.se> Date: 18 Sep 90 22:36:05 GMT References: <6929.26ed0b53@uwovax.uwo.ca> <6932.26ed237f@uwovax.uwo.ca> <26553@mimsy.umd.edu> Sender: news@eua.ericsson.se Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden Lines: 29 In article <26553@mimsy.umd.edu> chris@mimsy.umd.edu (Chris Torek) writes: >In article <6932.26ed237f@uwovax.uwo.ca> miller@uwovax.uwo.ca >>if ( { test -s /usr/spool/mail/miller } ) then; echo "" ; echo "New mail" ;\ >> echo "" ; endif >This is the C shell we are talking about. Do not expect anything >resembling sanity. Quite. Following the eternal wisdom of the net, I have learned not only "if you want to do a non-trivial csh script, use sh" but also "if you want to do a non-trivial csh command, use sh". Thus, a working one-liner could be: sh -c 'if test -s /usr/spool/mail/miller; then echo ""; echo "New mail"; echo ""; fi' However, turning this into an alias with csh's idea of quoting is awkward if at all possible, and you might just as well make it a script. Actually, IMHO the best solution is to use the other conditional construct, that happens to be common to sh and csh, and apparently unbroken in the latter: test -s /usr/spool/mail/miller && (echo ""; echo "New mail"; echo "") or as an alias: alias mailtest 'test -s /usr/spool/mail/miller && (echo ""; echo "New mail"; echo "")' --Per Hedeland per@erix.ericsson.se or per%erix.ericsson.se@uunet.uu.net or ...uunet!erix.ericsson.se!per