summaryrefslogtreecommitdiffhomepage
path: root/subr.rtl/rtl_complex.subr
diff options
context:
space:
mode:
authorLucía Andrea Illanes Albornoz <lucia@luciaillanes.de>2023-03-20 19:25:58 +0100
committerLucía Andrea Illanes Albornoz <lucia@luciaillanes.de>2023-03-20 19:26:38 +0100
commit550c1831733f61c4af8e32179dc7df39bcd7a1de (patch)
tree4c438bb98ba691c0547dd1034128b046ffcc75b5 /subr.rtl/rtl_complex.subr
parent4ad93ea7d03277735a8688943d00645dda4efc94 (diff)
downloadmidipix_build-550c1831733f61c4af8e32179dc7df39bcd7a1de.tar.bz2
midipix_build-550c1831733f61c4af8e32179dc7df39bcd7a1de.tar.xz
Document subr.rtl/*.subr functions, pt. I.
Diffstat (limited to 'subr.rtl/rtl_complex.subr')
-rw-r--r--subr.rtl/rtl_complex.subr49
1 files changed, 29 insertions, 20 deletions
diff --git a/subr.rtl/rtl_complex.subr b/subr.rtl/rtl_complex.subr
index 0a475d07..64fcea57 100644
--- a/subr.rtl/rtl_complex.subr
+++ b/subr.rtl/rtl_complex.subr
@@ -4,9 +4,10 @@
#
#
-# rtl_export_vars() -
-# @_unsetfl:
-#
+# rtl_export_vars() - export or unset list of variables
+# @[-u]: unset instead of exporting variables
+# @...: list of variable name-value pairs
+#
# Returns: zero (0) on success, non-zero (>0) on failure
#
rtl_export_vars() {
@@ -30,21 +31,14 @@ rtl_export_vars() {
return 0;
};
-rtl_head() {
- local _rh_pattern="${1}" _rh_s="${2}" _rh_rs_out="${3#\$}";
-
- while true; do
- if [ "${_rh_s%%${_rh_pattern}}" = "${_rh_s}" ]; then
- break;
- else
- _rh_s="${_rh_s%%${_rh_pattern}}";
- fi;
- done;
-
- eval ${_rh_rs_out}='${_rh_s}';
- return 0;
-};
-
+#
+# rtl_percentage() - calculate percentage of two numbers
+# @_in: input number
+# @_max: input maximum
+# @_rs_out: out reference to percentage number
+#
+# Returns: zero (0) on success, non-zero (>0) on failure
+#
rtl_percentage() {
local _rp_in="${1}" _rp_max="${2}" _rp_rs_out="${3#\$}" \
_rp_perc;
@@ -56,6 +50,14 @@ rtl_percentage() {
return 0;
};
+#
+# rtl_percentage2() - calculate percentage of two numbers
+# @_rin: in reference to input number
+# @_rmax: in reference to input maximum
+# @_rs_out: out reference to percentage number
+#
+# Returns: zero (0) on success, non-zero (>0) on failure
+#
rtl_percentage2() {
local _rp_rin="${1#\$}" _rp_rmax="${2#\$}" _rp_rs_out="${3#\$}" \
_rp_in=0 _rp_max=0 _rp_perc;
@@ -70,12 +72,19 @@ rtl_percentage2() {
return 0;
};
+#
+# rtl_sunset() - unset variables
+# @_rset: in reference to list of variables to unset
+#
+# Returns: zero (0) on success, non-zero (>0) on failure
+#
rtl_sunset() {
- local _rs_rset="${1#\$}" _rs_kname="" IFS=" ";
+ local _rs_rset="${1#\$}" \
+ IFS=" ";
eval set -- "\${${_rs_rset}}";
while [ "${#}" -gt 0 ]; do
- unset "${_rs_rset}${_rs_kname}"; shift;
+ unset "${_rs_rset}"; shift;
done; unset "${_rs_rset}";
return 0;