Subject: long vs. int bug in /bin/test Index: bin/test.c 2.11BSD Description: Numeric comparisions in /bin/test are being done using "int" instead of "long"s. This causes problems for numbers larger than 32767. Repeat-By: if test 20000 -gt 50000; then echo 20000 is greater than 50000 ha ha ha fi Fix: Apply this patch to test.c and recompile. Make sure that /bin/[ remains a link to /bin/test after installation of the new version of /bin/test. --------------------------------------------------------------------- *** test.c.old Sun Feb 8 17:24:53 1987 --- test.c Tue Aug 27 08:53:52 1991 *************** *** 19,24 **** --- 19,25 ---- char **av; char *tmp; char *nxtarg(); + extern long atol(); main(argc, argv) char *argv[]; *************** *** 79,85 **** int p1; register char *a; char *p2; ! int int1; a=nxtarg(0); if(EQ(a, "(")) { --- 80,86 ---- int p1; register char *a; char *p2; ! long int1; a=nxtarg(0); if(EQ(a, "(")) { *************** *** 126,145 **** if(EQ(a, "-l")) { int1=length(p2); p2=nxtarg(0); ! } else{ int1=atoi(a); } if(EQ(p2, "-eq")) ! return(int1==atoi(nxtarg(0))); if(EQ(p2, "-ne")) ! return(int1!=atoi(nxtarg(0))); if(EQ(p2, "-gt")) ! return(int1>atoi(nxtarg(0))); if(EQ(p2, "-lt")) ! return(int1=atoi(nxtarg(0))); if(EQ(p2, "-le")) ! return(int1<=atoi(nxtarg(0))); --ap; return(!EQ(a,"")); --- 127,146 ---- if(EQ(a, "-l")) { int1=length(p2); p2=nxtarg(0); ! } else{ int1=atol(a); } if(EQ(p2, "-eq")) ! return(int1==atol(nxtarg(0))); if(EQ(p2, "-ne")) ! return(int1!=atol(nxtarg(0))); if(EQ(p2, "-gt")) ! return(int1>atol(nxtarg(0))); if(EQ(p2, "-lt")) ! return(int1=atol(nxtarg(0))); if(EQ(p2, "-le")) ! return(int1<=atol(nxtarg(0))); --ap; return(!EQ(a,""));