[comp.os.minix] commands/test.c - bug + fix ????

bert@bebux.UUCP (Bert Reuling) (01/11/89)

     It  seems  I've  found  a bug in test(1) as distributed with
     MINIX-ST v.1.1. "test <a> -eq <b> <c>" always returns false,
     even if <a> == <b>. Test without arguments returns non-zero,
     but prints a syntax error as well. I have tested test(1)  on
     DYNIX  (BSD4.2 and SV), HP-UX (SV) , v7 and SV/386. They all
     remain silent, but return non-zero. I don't know if this bug
     was  reported  earlier or if it applies to MINIX-PC as well.
     Anyway, here is the diff of the patch I made.


     86,88c86,90
     <  prog = argv[0];
     <  ip = &argv[1];
     <  exit(!(expr(lex(*ip)) && *++ip == 0));
     ---
     >  if (argc == 1)
     >          exit(1);
     >  prog = argv[0];
     >  ip = &argv[1];
     >  exit(!expr(lex(*ip)));



                       ...!hp4nl!bebux!bert


                  /             /      Bert Reuling
                 /-,  ,--, ,-, /-      p/a Radio Holland bv
                /  / /--- /   /        Jan Rebelstraat 20
                `-'  `--  `   `--      1069 CC Amsterdam
                                       The Netherlands


                   MINIX werkgroep UNIXgg/HCC