summaryrefslogtreecommitdiffhomepage
path: root/subr
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2020-05-15 10:18:14 +0100
committerLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2020-05-15 10:18:14 +0100
commit0875f53f8892f65bda62caa0d35d1b8dd44c6efc (patch)
tree4275404fa50ce151c0cd79c17494e74f6971858f /subr
parent64c9461a9513839bae0b1e30013febc26fad1cec (diff)
downloadmidipix_build-0875f53f8892f65bda62caa0d35d1b8dd44c6efc.tar.bz2
midipix_build-0875f53f8892f65bda62caa0d35d1b8dd44c6efc.tar.xz
subr/rtl_list.subr:rtl_l{assign,first}(): initial implementation.
subr/pkg_install.subr:pkg_install(): use rtl_lassign().
Diffstat (limited to 'subr')
-rw-r--r--subr/pkg_install.subr4
-rw-r--r--subr/rtl_list.subr24
2 files changed, 26 insertions, 2 deletions
diff --git a/subr/pkg_install.subr b/subr/pkg_install.subr
index ee6c783c..a3784992 100644
--- a/subr/pkg_install.subr
+++ b/subr/pkg_install.subr
@@ -23,11 +23,11 @@ pkgp_install_perms() {
};
pkg_install() {
- local _destdir="" _destdir_prefix="" _ifs_old="${IFS:- }" _pkglist_name="" IFS;
+ local _destdir="" _destdir_prefix="" _pkglist_name="";
if ! rtl_fileop mkdir "${PKG_PREFIX}"; then
return 1;
else for _destdir in "${PKG_DESTDIR}:${PKG_PREFIX}" "${PKG_DESTDIR_HOST}:${PREFIX}"; do
- IFS=":"; set -- ${_destdir}; IFS="${_ifs_old}"; _destdir="${1}"; _destdir_prefix="${2}";
+ rtl_lassign "_destdir _destdir_prefix" ":" "${_destdir}";
if [ -e "${_destdir}" ]; then
pkgp_install_perms "${_destdir}";
(set +o errexit -o noglob; rtl_flock_acquire 4 || exit "${?}"; date;
diff --git a/subr/rtl_list.subr b/subr/rtl_list.subr
index 515681bc..369d3b46 100644
--- a/subr/rtl_list.subr
+++ b/subr/rtl_list.subr
@@ -2,6 +2,20 @@
# set +o errexit -o noglob -o nounset is assumed.
#
+rtl_lassign() {
+ local _vnames="${1}" _sep="${2}" _vname="" _vval=""\
+ IFS RTL_LFIRST_HEAD="" RTL_LFIRST_TAIL="";
+ IFS="${_sep}"; shift 2;
+ for _vval in ${@}; do
+ if ! rtl_lfirst "${_vnames}" " "; then
+ return 1;
+ else
+ _vname="${RTL_LFIRST_HEAD}"; _vnames="${RTL_LFIRST_TAIL}";
+ rtl_set_var_unsafe "${_vname}" "${_vval}";
+ fi;
+ done;
+};
+
rtl_lconcat() {
local _list="${1}" _litem_new="${2}" _sep="${3:- }" IFS="${3:-${IFS:- }}";
if [ -n "${_list}" ]; then
@@ -30,6 +44,16 @@ rtl_lfilter() {
printf "%s" "${_lnew}";
};
+rtl_lfirst() {
+ local _list="${1}" _sep="${2}" IFS; IFS="${_sep}";
+ set -- ${_list}; RTL_LFIRST_HEAD="${1}";
+ if [ "${#}" -ge 0 ]; then
+ shift; RTL_LFIRST_TAIL="${*}";
+ else
+ RTL_LFIRST_TAIL="";
+ fi;
+};
+
rtl_llength() {
local _list="${1}" _sep="${2:- }" IFS="${2:-${IFS:- }}" _litem="" _llength=0;
for _litem in ${_list}; do