Path: utzoo!mnetor!uunet!dalcs!thompson From: thompson@dalcs.UUCP (Michael Thompson) Newsgroups: comp.bugs.4bsd Subject: Re: csh arithmetic bug Message-ID: <2830@dalcs.UUCP> Date: 11 Apr 88 13:31:52 GMT References: <23570@ucbvax.BERKELEY.EDU> Reply-To: thompson@dalcs.UUCP (Michael Thompson) Organization: Math, Stats & CS, Dalhousie University, Halifax, NS, Canada Lines: 23 In article <23570@ucbvax.BERKELEY.EDU> ph@miro.Berkeley.EDU (Paul Heckbert) writes: >Beware of doing arithmetic in csh, it's buggy! >The command @ x = 0 - 1 + 2 sets x to -3 (should be 1) >The command @ x = 0 - 1 - 2 sets x to 1 (should be -3) >(same error with Sun UNIX 3.5 on Sun3 and 4.3 BSD on Vax780) > >csh must be parsing right-associatively by mistake! >Division has a similar problem. >It's hard to believe that a bug like this would persist for 8 years. The following is extracted from the csh man page: * / % multiplication, division, remainder (These are right associative, which can lead to unexpected results. Group combinations explicitly with parentheses.) + - addition, subtraction (also right associative) -- <<<<<<******>>>>>> Michael A. Thompson, Dept. Math, Stats, & C.S., Dalhousie U., Halifax, N.S. thompson@dalcs.uucp | thompson@cs.dal.cdn | thompson@dal1.bitnet (902)424-6501