Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.sources.bugs Subject: Re: Use of && and || in sh / csh Message-ID: <2164@sun.uucp> Date: Thu, 9-May-85 03:14:47 EDT Article-I.D.: sun.2164 Posted: Thu May 9 03:14:47 1985 Date-Received: Fri, 10-May-85 23:58:54 EDT References: <1502@dalcs.UUCP> Organization: Sun Microsystems, Inc. Lines: 32 > I have a problem with the Unisoft 2.4 on my Wicat which does not > appear under 4.2 -- the sense of && and || are reversed when run > under csh. ... Is this a unique bug in Unisoft Unix, or is there a > rationale to the difference? It's a bug; I don't know if it's unique to Unisoft UNIX or (as I suspect) it's common to all "csh"s that are derived from a pre-4.1BSD version. The code with the problem is from "sh.sem.c"; it should look something like this: case TOR: case TAND: if (t->t_dcar) { t->t_dcar->t_dflg |= t->t_dflg & FINT; execute(t->t_dcar, wanttty); if ((getn(value("status")) == 0) != (t->t_dtyp == TAND)) return; } if (t->t_dcdr) { t->t_dcdr->t_dflg |= t->t_dflg & (FPAR|FINT); execute(t->t_dcdr, wanttty); } break; If I remember correctly, the bug is that the comparison operator comparing the two boolean expressions in the line with 'value("status")' in it is an ==, rather than a !=. Either that, or one of the "=="s was an "!=". (The author probably forgot that the shell convention for "true" and "false" was that "true" was 0 and "false" was non-zero). Guy Harris