[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash incompatible with sh,maybe this is a bug
From: |
Andreas Schwab |
Subject: |
Re: bash incompatible with sh,maybe this is a bug |
Date: |
Tue, 25 Dec 2007 10:54:57 +0100 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (gnu/linux) |
showrun.lee <showrun.lee@gmail.com> writes:
> [ ! "$test" -a "$test1" ] && test="papa";
This is a test with four arguments, thus the rules are:
• If $1 is ’!’, negate the three-argument test of $2, $3, and $4.
• If $1 is ’(’ and $4 is ’)’, perform the two-argument test of $2 and $3.
• Otherwise, the results are unspecified.
Since "$test" -a "$test1" is false, the test comes out as true.
Using test with a combination of more than one primary operator is not
recommended.
> I think ,this is a bug in bash.and i test it on many freebsd release 4.11,
> 6.1,6.2 with default bash version,this is same.
Your /bin/sh is not POSIX compliant.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."