diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2022-04-11 00:18:04 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2022-04-11 00:18:04 +0200 |
commit | 31bcc5c263aea983e967426e2b94269e7605dcd4 (patch) | |
tree | 7b48ad9d7799afe09b7d7d8adc980bd5db935bdf /Functions/Math | |
parent | 5086b5356abcef8849dc8a09902b7c55f01db3c0 (diff) | |
parent | b09f4483416c54c1782824633dfabaf2ec0265b6 (diff) | |
download | zsh-31bcc5c263aea983e967426e2b94269e7605dcd4.tar.gz zsh-31bcc5c263aea983e967426e2b94269e7605dcd4.zip |
Update upstream source from tag 'upstream/5.8.1.2-test'
Update to upstream version '5.8.1.2-test'
with Debian dir b380d582bf51cd93149e4dea28fffa1ad85db4f5
Diffstat (limited to 'Functions/Math')
-rw-r--r-- | Functions/Math/zmathfunc | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/Functions/Math/zmathfunc b/Functions/Math/zmathfunc index 4ff40700d..12d2c2f3d 100644 --- a/Functions/Math/zmathfunc +++ b/Functions/Math/zmathfunc @@ -1,34 +1,50 @@ #autoload zsh_math_func_min() { + emulate -L zsh local result=$1 shift local arg for arg ; do - (( $arg < result )) && result=$arg + (( arg < result )) + case $? in + (0) (( result = arg ));; + (1) ;; + (*) return $?;; + esac done - (( result )) # return + (( result )) + true # Careful here: `return 0` evaluates an arithmetic expression } functions -M min 1 -1 zsh_math_func_min # at least one argument zsh_math_func_max() { + emulate -L zsh local result=$1 shift local arg for arg ; do - (( $arg > result )) && result=$arg + (( arg > result )) + case $? in + (0) (( result = arg ));; + (1) ;; + (*) return $?;; + esac done - (( result )) # return + (( result )) + true # Careful here: `return 0` evaluates an arithmetic expression } functions -M max 1 -1 zsh_math_func_max # at least one argument zsh_math_func_sum() { + emulate -L zsh local sum local arg for arg ; do - (( sum += $arg )) + (( sum += arg )) done (( sum )) + true # Careful here: `return 0` evaluates an arithmetic expression } functions -M sum 0 -1 zsh_math_func_sum |