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

Tony J Yeates yeates at motcid.UUCP
Fri Feb 15 08:41:06 AEST 1991


harichan at eecae.uucp (Ronald Harichandran) writes:

>Is it possible to have an if-then-else-endif block on a single line?

If () command

I found this buggy on the version of csh I used, so I don't use this form
anymore.  Also, I don't think you can use "else" with it.

>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

The only thing I can think of is:-

if () then ; command ; else ; command ; endif

which when I try it does NOT work.

The csh man page says "The words else and endif must be the first nonwhite
characters on a line."  Oh, it also describes the if() command bug mentioned above.
Guess we're SOL!



More information about the Comp.unix.shell mailing list