Many programs open code these functionalities so add it as a generic helper in common/rc Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx> Signed-off-by: Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx> --- common/rc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/common/rc b/common/rc index ff5df203..35a1c835 100644 --- a/common/rc +++ b/common/rc @@ -5975,6 +5975,28 @@ _require_inplace_writes() fi } +_min() { + local ret + + for arg in "$@"; do + if [ -z "$ret" ] || (( $arg < $ret )); then + ret="$arg" + fi + done + echo $ret +} + +_max() { + local ret + + for arg in "$@"; do + if [ -z "$ret" ] || (( $arg > $ret )); then + ret="$arg" + fi + done + echo $ret +} + ################################################################################ # make sure this script returns success /bin/true -- 2.49.0