Subject: /bin/test needlessly strict
To: None <netbsd-bugs@sun-lamp.cs.berkeley.edu>
From: Simon J. Gerraty <sjg@zen.void.oz.au>
List: netbsd-bugs
Date: 11/06/1993 18:35:40
C-news uses a construct like
if test " `command`" -gt 1
then
...
fi
Which equates to " 2" for instance so that even when `command` returns
nothing the test command has the right number of arguments. On other
systems /bin/test is happy about the leading space, but BSD gets upset
giving the error:
test: illegal operand " 2" -- expected integer.
the following patch, skips over any leading white-space before
checking for digits. You might want to use isspace() but this seemed
adequate.
*** test.c~ Tue Jun 15 16:22:27 1993
--- test.c Sat Nov 6 18:22:05 1993
***************
*** 521,526 ****
--- 521,528 ----
{
char *p;
+ while (*v == ' ' || *v == '\t')
+ v++;
for (p = v; *p != '\0'; p++)
if (!isdigit(*p))
err("illegal operand \"%s\" -- expected integer.", v);
------------------------------------------------------------------------------