diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-30 20:58:39 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-30 20:58:39 +1300 |
commit | 36636d4b55bc9189b013fd8ccacb12e8070232b3 (patch) | |
tree | 368b14b5e60afd5aee96d46f4033b10c971c76e3 | |
parent | Add line deletion to StripTrailingWhitespace() (diff) | |
download | dotfiles-36636d4b55bc9189b013fd8ccacb12e8070232b3.tar.gz dotfiles-36636d4b55bc9189b013fd8ccacb12e8070232b3.zip |
Refactor min.awk to match max.awk
This is more idiomatic, and explicitly initialises the result variable.
-rw-r--r-- | bin/min.awk | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/bin/min.awk b/bin/min.awk index c58a3a8f..18f65889 100644 --- a/bin/min.awk +++ b/bin/min.awk @@ -1,8 +1,6 @@ # Get the minimum of a list of numbers -{ - if (NR == 1 || $1 < min) - min = $1 -} +BEGIN { min = 0 } +NR == 1 || $1 < min { min = $1 + 0 } END { if (!NR) exit(1) |