summaryrefslogtreecommitdiffhomepage
path: root/subr/rtl_string.subr
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2020-03-11 16:09:22 +0000
committerLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2020-03-11 16:09:22 +0000
commit8a27f992e5b7c62e144dbbfc3435a90c470d92a4 (patch)
tree52aa6aabc1ab3c79a0475bed758828d316180377 /subr/rtl_string.subr
parentfca18e9d6857d335027d012d462f61ac648ef93a (diff)
downloadmidipix_build-8a27f992e5b7c62e144dbbfc3435a90c470d92a4.tar.bz2
midipix_build-8a27f992e5b7c62e144dbbfc3435a90c470d92a4.tar.xz
Initial implementation of pkgtool.sh.
build.sh:build(): move cd(1) to $(dirname "${0}"). etc/{build.usage,README.md}: updated. midipix.env:${DEFAULT_CLEAR_ENV_VARS_EXCEPT}: allow inheriting ARCH, BUILD, BUILD_DLCACHEDIR, BUILD_WORKDIR, and PREFIX* from the environment. pkgtool.sh: initial implementation. subr/build_init.subr:buildp_init_defaults(): allow inheriting ARCH, BUILD, BUILD_DLCACHEDIR, BUILD_WORKDIR, and PREFIX* from the environment. subr/build_init.subr:buildp_init_env(): move cd(1) to $(dirname "${0}"). subr/build_init.subr:buildp_init_files(): correctly pass ${_status} from rtl_check_path_vars(). subr/ex_pkg_exec.subr:ex_pkg_exec(): dump subset of variables and exported variables on build failure and --dump-on-abort. subr/pkgtool_init.subr: adapted from subr/build_init.subr. subr/rtl_complex.subr:rtl_filter_vars(): initial implementation. subr/rtl_string.subr:rtl_subst(): initial implementation.
Diffstat (limited to 'subr/rtl_string.subr')
-rw-r--r--subr/rtl_string.subr11
1 files changed, 11 insertions, 0 deletions
diff --git a/subr/rtl_string.subr b/subr/rtl_string.subr
index 0e549d3c..2d529786 100644
--- a/subr/rtl_string.subr
+++ b/subr/rtl_string.subr
@@ -12,6 +12,17 @@ rtl_isnumber() {
return "${_rc}";
};
+rtl_subst() {
+ local _s="${1}" _find="${2}" _replace="${3}" _prefix="" _s_new="";
+ while [ -n "${_s}" ]; do
+ case "${_s}" in
+ *${_find}*) _prefix="${_s%%${_find}*}"; _s="${_s#*${_find}}";
+ _s_new="${_s_new:+${_s_new}}${_prefix}${_replace}"; ;;
+ *) _s_new="${_s_new:+${_s_new}}${_s}"; _s=""; ;;
+ esac; done;
+ echo "${_s_new}";
+};
+
rtl_tolower() {
local _s="${1}" _s_new="";
while [ -n "${_s}" ]; do