From b6a9a1a3c8b98077cce47d579069c42080d17da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Sun, 15 Mar 2020 09:14:23 +0000 Subject: General cleanup. --- subr/rtl_string.subr | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'subr/rtl_string.subr') diff --git a/subr/rtl_string.subr b/subr/rtl_string.subr index c30cfe8c..2dd9e27a 100644 --- a/subr/rtl_string.subr +++ b/subr/rtl_string.subr @@ -21,6 +21,15 @@ rtl_match() { fi; }; +rtl_matchr() { + local _s="${1}" _find="${2}"; + if [ "${_s%${_find}}" != "${_s}" ]; then + return 0; + else + return 1; + fi; +}; + rtl_subst() { local _s="${1}" _find="${2}" _replace="${3}" _prefix="" _s_new=""; while [ -n "${_s}" ]; do @@ -29,7 +38,7 @@ rtl_subst() { _s_new="${_s_new:+${_s_new}}${_prefix}${_replace}"; ;; *) _s_new="${_s_new:+${_s_new}}${_s}"; _s=""; ;; esac; done; - echo "${_s_new}"; + printf "%s" "${_s_new}"; }; rtl_tolower() { @@ -68,7 +77,7 @@ rtl_tolower() { _s="${_s#[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]}"; done; ;; esac; done; - echo "${_s_new}"; + printf "%s" "${_s_new}"; }; rtl_toupper() { @@ -107,7 +116,7 @@ rtl_toupper() { _s="${_s#[^abcdefghijklmnopqrstuvwxyz]}"; done; ;; esac; done; - echo "${_s_new}"; + printf "%s" "${_s_new}"; }; # vim:filetype=sh -- cgit v1.2.3