Re: Some issues with short-circuiting arithmetic operators

2012-09-09 Thread Chet Ramey
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 9/5/12 10:40 PM, Dan Douglas wrote: > This reorder function is meant to swap values of a two-element array if > unordered. Bash and ksh produce reversed results. mksh and zsh do as expected. [...] > The Ksh issue seems to be that an explicit

Some issues with short-circuiting arithmetic operators

2012-09-05 Thread Dan Douglas
This reorder function is meant to swap values of a two-element array if unordered. Bash and ksh produce reversed results. mksh and zsh do as expected. #!/usr/bin/env bash [[ -n ${ZSH_VERSION+_} ]] && emulate ksh function reorder { (( x[1] < x && (x=x[1], x[1]=$x) )) e