Oliver Kiddle <[EMAIL PROTECTED]> writes:

> The following is a bug reported for the Debian ksh package. Thanks

[...]

> According to POSIX[*], "test \( ! -e \)" is a 4-argument test and is
> here equivalent to "test ! -e".

Where specifically does the POSIX standard say that?  I read

 $ test \( ! -e \)

as an instance of "( expression )".  However, the expresion is
malformed because "-e" does not have an argument.  So what actually
happens is that "-e" takes ")" as the filename.  But now we have an
expression of the form "( expression", which is a syntax error.  This
is exactly what FreeBSD's and NetBSD's /bin/test say:

  $ /bin/test \( ! -e \); echo $?
  test: closing paren expected
  2

Bash's builtin test, too:

  $ test \( ! -e \); echo $?
  bash: test: `)' expected
  2

The Gnu test's solution of treating "test \( ! -e \);" as "test ! -e;"
may be nice, but it requires the parser to be *very* forgiving, which
IMO is not always a good thing.

> But ksh93 yields an error:
>
> $ test \( ! -e \) || echo $?
> ksh93: test: argument expected
> 2
> $ test ! -e || echo $?      
> 1

I think Ksh is even better here than other shells because it correctly
figures out what we intended to do.

-- 
Wolfram Fenske

A: Yes.
>Q: Are you sure?
>>A: Because it reverses the logical flow of conversation.
>>>Q: Why is top posting frowned upon?
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to