One line If-then-else block in csh possible?

Tom Christiansen tchrist at convex.COM
Sun Feb 17 01:21:34 AEST 1991


>From the keyboard of harichan at eecae.uucp (Ronald Harichandran):
:Is it possible to have an if-then-else-endif block on a single line?
:
:I wish to do something like
:
:if () then
:  command
:else
:  command
:endif
:
:but wish to have it in a single line like
:
:if () then, command, else, command, endif

You can often  work something out using /bin/test and the short-circuit
booleans:

    [ some test ] && success || failure

Evals might be coerced into helping -- haven't thought about that too much.

In general, your happiness with csh will be inversely proportional to how
much you try to do with it.

--tom
--
Tom Christiansen		tchrist at convex.com	convex!tchrist
 "All things are possible, but not all expedient."  (in life, UNIX, and perl)



More information about the Comp.unix.shell mailing list