bug in CSH (history)
chris
chris at pixutl.UUCP
Sat Oct 6 04:01:13 AEST 1984
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
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list