bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'test' builtin of bash returns wrong value for '! -a FILE' operation


From: Greg Wooledge
Subject: Re: 'test' builtin of bash returns wrong value for '! -a FILE' operation
Date: Tue, 9 Nov 2010 08:58:58 -0500
User-agent: Mutt/1.4.2.3i

On Tue, Nov 09, 2010 at 08:29:15PM +0900, OZAKI Masanobu wrote:
> Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> > (On my system, there is no -a unary operator in the test(1) man page, but
> > the command apparently supports one, undocumented.  Isn't this fun?)
> 
> Neither on my system.  I found descriptions of the -a unary operator
> in the output of "help test" output and ksh(1) man page.
> According to Solaris 7's test(1) page
> (http://docs.sun.com/app/docs/doc/805-3172/6j31br5p3?l=en&a=view),
> which summarizes variations of test command, I guess this is ksh origin
> and influenced (or polluted?:) /bin/test and bash.

It's difficult to figure out who first introduced an extension.  Most
of these things predate POSIX, and were extensions to either SVID or
BSD standards.  POSIX had the unenviable job of deciding which features
were common enough to mark as "standard" and which were not.

On a different note, that man page is rather dodgy.  It says

  /usr/bin/test [condition]

and then

  if condition ; then action ; fi

Are they saying that Solaris's sh would accept this?

  if -d /etc; then echo "good, you have /etc"; fi

That's what it LOOKS like it's saying, but surely that can't be right....

> I found the
> inconsistency between bash-builtin and GNU shell util's test commands when
> porting a ksh script to bash in order to avoid a ksh's bug that randomly
> occurred on Scientific Linux.

"It's easier to port a shell than a shell script." -- Larry Wall



reply via email to

[Prev in Thread] Current Thread [Next in Thread]