Skip to content

Commit 650c664

Browse files
johnpgarrykawasaki
authored andcommitted
common/rc: add _min()
Add a helper to find the minimum of two numbers. A similar helper is being added in xfstests: https://lore.kernel.org/linux-xfs/[email protected]/T/#m962683d8115979e57342d2644660230ee978c803 Signed-off-by: John Garry <[email protected]> Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent f01227d commit 650c664

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

common/rc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,3 +701,14 @@ _real_dev()
701701
fi
702702
echo "$dev"
703703
}
704+
705+
_min() {
706+
local ret
707+
708+
for arg in "$@"; do
709+
if [ -z "$ret" ] || (( arg < ret )); then
710+
ret="$arg"
711+
fi
712+
done
713+
echo "$ret"
714+
}

0 commit comments

Comments
 (0)