Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz e1d469
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz c6d6e0
rtl_lconcat() {
Lucio Andrés Illanes Albornoz e58399
	local _list="${1}" _litem_new="${2}" _sep="${3:- }" IFS="${3:-${IFS:- }}";
Lucio Andrés Illanes Albornoz 2b85d0
	if [ -n "${_list}" ]; then
Lucio Andrés Illanes Albornoz 2b85d0
		printf "%s%s%s" "${_list}" "${_sep}" "${_litem_new}";
Lucio Andrés Illanes Albornoz 2b85d0
	else
Lucio Andrés Illanes Albornoz 2b85d0
		printf "%s" "${_litem_new}";
Lucio Andrés Illanes Albornoz 2b85d0
	fi;
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz c6d6e0
rtl_lfilter() {
Lucio Andrés Illanes Albornoz e58399
	local	_list="${1}" _filter="${2}" _sep="${3:- }" IFS="${3:-${IFS:- }}"\
Lucio Andrés Illanes Albornoz 2b85d0
		_filterfl="" _litem="" _litem_filter="" _lnew="";
Lucio Andrés Illanes Albornoz 2b85d0
	if [ -z "${_filter}" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
		printf "%s" "${_list}"; return 0;
Lucio Andrés Illanes Albornoz 2b85d0
	else for _litem in ${_list}; do
Lucio Andrés Illanes Albornoz 2b85d0
		_filterfl=0;
Lucio Andrés Illanes Albornoz 2b85d0
		for _litem_filter in ${_filter}; do
Lucio Andrés Illanes Albornoz 2b85d0
			if [ "${_litem_filter}" = "${_litem}" ]; then
Lucio Andrés Illanes Albornoz 2b85d0
				_filterfl=1; break;
Lucio Andrés Illanes Albornoz 2b85d0
			fi;
Lucio Andrés Illanes Albornoz 2b85d0
		done;
Lucio Andrés Illanes Albornoz 2b85d0
		if [ "${_filterfl:-0}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz 2b85d0
			_lnew="${_lnew:+${_lnew}${_sep}}${_litem}";
Lucio Andrés Illanes Albornoz 2b85d0
		fi;
Lucio Andrés Illanes Albornoz 2b85d0
	done; fi;
Lucio Andrés Illanes Albornoz b6a9a1
	printf "%s" "${_lnew}";
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz c6d6e0
rtl_llength() {
Lucio Andrés Illanes Albornoz e58399
	local _list="${1}" _sep="${2:- }" IFS="${2:-${IFS:- }}" _litem="" _llength=0;
Lucio Andrés Illanes Albornoz 2b85d0
	for _litem in ${_list}; do
Lucio Andrés Illanes Albornoz 2b85d0
		: $((_llength+=1));
Lucio Andrés Illanes Albornoz 2b85d0
	done;
Lucio Andrés Illanes Albornoz b6a9a1
	printf "%s" "${_llength}";
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz 974685
rtl_llift() {
Lucio Andrés Illanes Albornoz 974685
	local _list="${1}" _sep="${2}" _sep_new="${3}" IFS; IFS="${_sep}";
Lucio Andrés Illanes Albornoz 974685
	set -- ${_list}; IFS="${_sep_new}";
Lucio Andrés Illanes Albornoz b6a9a1
	printf "%s" "${*}";
Lucio Andrés Illanes Albornoz 974685
};
Lucio Andrés Illanes Albornoz 974685
Lucio Andrés Illanes Albornoz c6d6e0
rtl_lmatch() {
Lucio Andrés Illanes Albornoz e1d469
	local _list="${1}" _item="${2}" _sep="${3:- }";
Lucio Andrés Illanes Albornoz c6d6e0
	[ -n "$(rtl_lsearch "${_list}" "${_item}" "${_sep}")" ];
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz b6a9a1
rtl_lmax() {
Lucio Andrés Illanes Albornoz b6a9a1
	local _len=0 _len_max=0;
Lucio Andrés Illanes Albornoz b6a9a1
	while [ "${#}" -gt 0 ]; do
Lucio Andrés Illanes Albornoz b6a9a1
		_len="${#1}";
Lucio Andrés Illanes Albornoz b6a9a1
		if [ "${_len}" -gt "${_len_max}" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
			_len_max="${_len}";
Lucio Andrés Illanes Albornoz b6a9a1
		fi; shift;
Lucio Andrés Illanes Albornoz b6a9a1
	done; printf "%s" "${_len_max}";
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz c6d6e0
rtl_lsearch() {
Lucio Andrés Illanes Albornoz e58399
	local	_list="${1}" _filter="${2}" _sep="${3:- }" IFS="${3:-${IFS:- }}"\
Lucio Andrés Illanes Albornoz 2b85d0
		_litem="" _litem_filter="" _lnew="";
Lucio Andrés Illanes Albornoz 2b85d0
	if [ -z "${_filter}" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
		printf "%s" "${_list}"; return 0;
Lucio Andrés Illanes Albornoz 2b85d0
	else for _litem in ${_list}; do
Lucio Andrés Illanes Albornoz 2b85d0
		for _litem_filter in ${_filter}; do
Lucio Andrés Illanes Albornoz 2b85d0
			if [ "${_litem_filter}" = "${_litem}" ]; then
Lucio Andrés Illanes Albornoz 2b85d0
				_lnew="${_lnew:+${_lnew}${_sep}}${_litem}";
Lucio Andrés Illanes Albornoz 2b85d0
				break;
Lucio Andrés Illanes Albornoz 2b85d0
			fi;
Lucio Andrés Illanes Albornoz 2b85d0
		done;
Lucio Andrés Illanes Albornoz 2b85d0
	done; fi;
Lucio Andrés Illanes Albornoz b6a9a1
	printf "%s" "${_lnew}";
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz 60fba6
rtl_lsort() {
Lucio Andrés Illanes Albornoz 60fba6
	local _list="${1}" _sep="${2:- }";
Lucio Andrés Illanes Albornoz 60fba6
	printf "%s" "${_list}" | tr "${_sep}" "\n" | sort | paste -s -d "${_sep}";
Lucio Andrés Illanes Albornoz 60fba6
};
Lucio Andrés Illanes Albornoz 60fba6
Lucio Andrés Illanes Albornoz c6d6e0
rtl_lunfold_depends() {
Lucio Andrés Illanes Albornoz 763157
	local _vname_template="${1}" _depends="" _name="" _names=""; shift;
Lucio Andrés Illanes Albornoz 763157
	for _name in "${@}"; do
Lucio Andrés Illanes Albornoz c6d6e0
		if _depends="$(rtl_get_var_unsafe -u "$(eval printf \"%s\" \""${_vname_template}"\")")"\
Lucio Andrés Illanes Albornoz 763157
		&& [ -n "${_depends}" ]; then
Lucio Andrés Illanes Albornoz c6d6e0
			_depends="$(rtl_lunfold_depends "${_vname_template}" ${_depends})";
Lucio Andrés Illanes Albornoz c6d6e0
			_names="$(rtl_lconcat "${_names}" "${_depends}")";
Lucio Andrés Illanes Albornoz 763157
		fi;
Lucio Andrés Illanes Albornoz c6d6e0
		_names="$(rtl_lconcat "${_names}" "${_name}")";
Lucio Andrés Illanes Albornoz 763157
	done;
Lucio Andrés Illanes Albornoz b6a9a1
	printf "%s" "${_names}";
Lucio Andrés Illanes Albornoz 763157
};
Lucio Andrés Illanes Albornoz 763157
Lucio Andrés Illanes Albornoz 2b85d0
# vim:filetype=sh