Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site pixutl.UUCP Path: utzoo!linus!decvax!genrad!mit-eddie!godot!harvard!wjh12!pixel!pixutl!chris From: chris@pixutl.UUCP (chris) Newsgroups: net.bugs.4bsd Subject: bug in CSH (history) Message-ID: <56@pixutl.UUCP> Date: Fri, 5-Oct-84 14:01:13 EDT Article-I.D.: pixutl.56 Posted: Fri Oct 5 14:01:13 1984 Date-Received: Sun, 7-Oct-84 21:43:39 EDT Organization: Pixel Computer Inc., Wilmington, Mass. Lines: 62 There are a couple of bugs in the 'history' command of /bin/csh (and offspring, such as newcsh): 1) The maximum number of arguments to the history command is set to 2. 2) The validity of the flags is not checked and since the argument pointer is only incremented when a valid flag is found, using a wrong flag throws the Cshell in a loop. ------------- To duplicate, type: csh set history = 100 history -h -r 5 history -x ------------- To fix: 1) In sh.init.c, change the following line: "history", dohist, 0, 2, to: "history", dohist, 0, 4, 2) in sh.hist.c, change the following lines in dohist(): vp++; while (*vp && *vp[0] == '-') { if (*vp && eq(*vp, "-h")) { hflg++; vp++; } if (*vp && eq(*vp, "-r")) { rflg++; vp++; } } to: while (*++vp && **vp == '-') { while(*++*vp) switch(**vp) { case 'h': hflg++; break; case 'r': rflg++; break; case '-': /* ignore multiple '-'s */ break; default: printf("Unknown flag: -%c\n", **vp); error("Usage: history [-rh] [# of events]"); } } ----------------------------------------- -- Chris Bertin : (617) 657-8720 x2318 Pixel Computer Inc. : 260 Fordham Rd. : {allegra|ihnp4|cbosgd|ima|genrad|amd|harvard}\ Wilmington, Ma 01887 : !wjh12!pixel!pixutl!chris