YAkshBug

Steve Simmons scs at iti.org
Sat Feb 3 08:02:33 AEST 1990


jbm at uncle.UUCP (John B. Milton) writes:

>Well, bug or inconsistancy:

>if [ -f * ]; then echo yes; fi

>will print "yes" if there are one or more files when using /bin/sh, but
>not with ksh. Ksh gives a syntax error.

>if sh -c "test -f *"; then echo yes; fi

>Does work.

Inconsistancy.  Strictly speaking

	if [ -f a b ] ; then . . .

is incorrect.  The '-f' test takes one and only one arguement.  /bin/sh
silently ignores the extra, while /bin/ksh reports the error.  My source
on this is David Korn.  Interestingly enough, what would

	if [ -f a b -a -f c ] ; then ...

do?  How many arguements does sh ignore, and which ones?  'if [ -f a b ]'
is definately a shell bug waiting to happen, and while it was disturbing
to find the inconsistancy between the two I'd much prefer the error notice.

Steve



More information about the Unix-pc.general mailing list