silvert@dalcs.UUCP (Bill Silvert) (05/03/85)
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. For example, the command line test -s file && echo file is there will print the echo line if file exists and is not empty if run under sh, but the sense of the test is reversed and nothing is printed when I run under csh. Is this a unique bug in Unisoft Unix, or is there a rationale to the difference? -- Bill Silvert Marine Ecology Lab. Dartmouth, NS dalcs!biomel!bill
guy@sun.uucp (Guy Harris) (05/09/85)
> 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