Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [[ 0 =~ 1 || 1 = 0 ]] returns true



% set -x
% [[ 0 =~ 1 || 1 = 0 ]]
+zsh:2> [[ 0 -regex-match 1 || ! 1 == 0 ]]
% [[ 0 =~ 1 || 1 == 1 || 1 = 0 ]]
+zsh:3> [[ 0 -regex-match 1 || ! 1 == 1 ]]
% [[ 0 =~ 1 || 1 == 1 || 1 = 1 || 1 = 1 || 1 = 1 ]]
+zsh:4> [[ 0 -regex-match 1 || ! 1 == 1 ]]

It appears that zsh thinks it needs to invert the second conditional
expression. Also, zsh seems to drop more than two conditional
expressions.

Michael Hwang

On Sat, Oct 9, 2010 at 1:29 PM, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> % [[ 1 =~ 1 && 0 = 1 ]]; echo $?
> 0
> % [[ 1 =~ 1 || 0 = 1 ]]; echo $?
> 0
> % [[ 1 =~ 0 || 0 = 1 ]]; echo $?
> 0
> % [[ 1 =~ 0 || 1 = 1 ]]; echo $?
> 1
> % [[ 1 =~ 1 || 1 = 1 ]]; echo $?
> 0
> % [[ 1 =~ 1 && 1 = 1 ]]; echo $?
> 1
> % [[ 1 =~ 0 && 1 = 1 ]]; echo $?
> 1
>
> Something seems to be screwy with =~ and &&/||, on its own it appears fine.
>
> --
> Mikael Magnusson
>



Messages sorted by: Reverse Date, Date, Thread, Author