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

Re: if (()){}else{} documented?



On Tue, Apr 20, 2021, at 11:19 AM, Marc Chantreux wrote:
> all the following examples works fine there. i'm even surprised about
> this one
> 
> > joe(){ [[ $1 > 4 ]] && echo big || echo small }
> 
> this is a math expression so i would have written
> 
> joe(){ (( $1 > 4 )) && echo big || echo small }

You'd be right because the original version is wrong (unless OP
*wants* lexicographic comparison and just didn't say so).

	% joe(){ [[ $1 > 4 ]] && echo big || echo small }
	% joe 5
	big
	% joe 10
	small

-- 
vq




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