Help needed with conditional statement for alias in csh
Per Hedeland
per at erix.ericsson.se
Wed Sep 19 08:36:05 AEST 1990
In article <26553 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:
>In article <6932.26ed237f at uwovax.uwo.ca> miller at 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 at erix.ericsson.se or
per%erix.ericsson.se at uunet.uu.net or
...uunet!erix.ericsson.se!per
More information about the Comp.unix.shell
mailing list