Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham
	autolearn_force=no version=3.4.0
Message-ID: <56A0D7DE.5000407@inlv.org>
Date: Thu, 21 Jan 2016 14:06:38 +0100
From: Martijn Dekker <martijn@inlv.org>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
MIME-Version: 1.0
To: zsh-workers@zsh.org
CC: Peter Stephenson <p.stephenson@samsung.com>
Subject: [BUG] 'test' returns 1 (not >1) on error [was: test is not posix]
References: <20160120220614.18fe6683@enterprise> <56A01C67.1050509@inlv.org> <20160121124113.12e2d72a@pwslap01u.europe.root.pri>
In-Reply-To: <20160121124113.12e2d72a@pwslap01u.europe.root.pri>
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Seq: zsh-workers 37717

Peter Stephenson schreef op 21-01-16 om 13:41:
> Yes, we now have tests for the following cases.  It's trivial to add more
> if you can think of any that might be problematic.

Something I also noticed back in May, and which I'm now reminded of, is
that test/[ returns status 1, and not 2 or higher, if an error occurs.

$ [ x = a b ]
[: too many arguments
$ echo $?
1
$ [ 1 -eq ]
zsh: parse error: condition expected: 1
$ echo $?
1

This makes it impossible to test for the failure of test/[ using the
exit status.

POSIX says the status should be 2 or higher on error:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128_14

Thanks,

- Martijn

