summaryrefslogtreecommitdiffhomepage
path: root/subr/rtl_complex.subr
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2020-05-15 11:39:58 +0100
committerLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2020-05-15 11:39:58 +0100
commit285301936f15f7c746adf97413dd9b7d13902ce9 (patch)
tree757e3a14a9766f0ef3c8b4ada1d1941ec3765bb5 /subr/rtl_complex.subr
parent3382d9576f26d6ad8286255a3b4489cb57d67f7a (diff)
downloadmidipix_build-285301936f15f7c746adf97413dd9b7d13902ce9.tar.bz2
midipix_build-285301936f15f7c746adf97413dd9b7d13902ce9.tar.xz
subr/rtl_complex.subr:rtl_percentage(): initial implementation.
subr/ex_pkg_dispatch.subr:exp_pkg_dispatch_{expand_packages,group}(): use rtl_percentage().
Diffstat (limited to 'subr/rtl_complex.subr')
-rw-r--r--subr/rtl_complex.subr7
1 files changed, 7 insertions, 0 deletions
diff --git a/subr/rtl_complex.subr b/subr/rtl_complex.subr
index cb7c90bd..63175bed 100644
--- a/subr/rtl_complex.subr
+++ b/subr/rtl_complex.subr
@@ -192,6 +192,13 @@ rtl_kill_tree() {
fi;
};
+rtl_percentage() {
+ local _in="${1}" _max="${2}" _perc;
+ _perc="$((100 * ${_in} + ${_max} / 2))";
+ _perc="$((${_perc} ? ${_perc} / ${_max} : ${_perc}))";
+ printf "%d\n" "${_perc}";
+};
+
rtl_prompt() {
local _fmt="${1}" _choice=""; shift;
printf "${_fmt}? (y|N) " "${@}";