A new shell. Any takers?

Andrew H. Marrinson andy at xwkg.Icom.Com
Wed Jan 16 05:23:06 AEST 1991


gwc at root.co.uk (Geoff Clare) writes:

>Byron Rakitzis <byron at archone.tamu.edu> writes:

>The worst of the lot is:

>>if (command)
>>	command
>>if not
>>	command

>Why on earth use "if not" when "else" is the obvious thing to use?

I almost sent email asking this same question.  Then I realized why.
(At least, I think I realized.)  The if not command is not exactly the
same as an else.  True, in the above example it seems it could be
replaced with else to good effect, but consider:

	if (command) {
		if (command)
			command
	}
	if not
		command

I suspect the if not applies to the second if, not the first.  Naming
it else would cause people to expect it to apply to the first if, as
an else would.  Calling it if not makes it clear it is different from
else: it applies to the last if command run, and knows nothing about
the lexical structure of the script.

Do I get a cookie?
--
		Andrew H. Marrinson
		Icom Systems, Inc.
		Wheeling, IL, USA
		(andy at icom.icom.com)



More information about the Comp.unix.shell mailing list