Blame subr.rtl/rtl_list.subr

Lucio Andrés Illanes Albornoz 2b85d0
#
8d7a8a
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 LucĂ­a Andrea Illanes Albornoz <lucia@luciaillanes.de>
Lucio Andrés Illanes Albornoz e1d469
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz 370e98
# N.B.	Lists separated by SP, when passed to rtl_l*() w/ explicit IFS,
Lucio Andrés Illanes Albornoz 370e98
#	must specify "<SP><VT>" as IFS.
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 2b85d0
dbea96
#
dbea96
# rtl_lassignV() - assigns list of variables to list of values w/ separator
dbea96
# @_vnames:	list of variable names
dbea96
# @_sep:	single non-zero, possibly multi-character, separator
dbea96
# @...:		list as positional parameters
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
dbea96
rtl_lassignV() {
e9fa07
	local	_rla_vnames="${1}" _rla_sep="${2}"	\
e9fa07
		_rla_head="" _rla_tail="" _rla_vname="" _rla_vval="" IFS;
e9fa07
	IFS="${_rla_sep}"; shift 2;
e9fa07
e9fa07
	for _rla_vval in ${@}; do
e9fa07
		if ! rtl_lfirst \$_rla_head \$_rla_tail "${_rla_vnames}" " "; then
Lucio Andrés Illanes Albornoz 0875f5
			return 1;
Lucio Andrés Illanes Albornoz 0875f5
		else
e9fa07
			_rla_vname="${_rla_head}"; _rla_vnames="${_rla_tail}";
e9fa07
			rtl_set_var_unsafe "${_rla_vname}" "${_rla_vval}";
Lucio Andrés Illanes Albornoz 0875f5
		fi;
Lucio Andrés Illanes Albornoz 0875f5
	done;
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz 0875f5
};
Lucio Andrés Illanes Albornoz 0875f5
dbea96
#
dbea96
# rtl_lconcat() - concatenate list with item(s)
dbea96
# @_rlist:	inout reference to list
dbea96
# @_litem_new:	list item(s) to concatenate with
dbea96
# @[_sep]:	optional single non-zero, possibly multi-character, separator
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
Lucio Andrés Illanes Albornoz c6d6e0
rtl_lconcat() {
e9fa07
	rtl_lconcat2 "${1}" "${1}" "${2}" "${3:-}";
e9fa07
};
e9fa07
dbea96
#
dbea96
# rtl_lconcat2() - concatenate list with item(s)
dbea96
# @_rlist_new:	out reference to new list
dbea96
# @_rlist:	in reference to list
dbea96
# @_litem_new:	list item(s) to concatenate with
dbea96
# @[_sep]:	optional single non-zero, possibly multi-character, separator
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
e9fa07
rtl_lconcat2() {
e9fa07
	local	_rlc2_rlist_new="${1#\$}" _rlc2_rlist="${2#\$}" _rlc2_litem_new="${3}"	\
e9fa07
		_rlc2_sep="${4:- }" IFS="${4:-${IFS:- }}";
e9fa07
e9fa07
	if eval [ \"'${'${_rlc2_rlist}':+1}'\" = 1 ]; then
e9fa07
		eval ${_rlc2_rlist_new}='${'"${_rlc2_rlist}"'}${_rlc2_sep}${_rlc2_litem_new}';
Lucio Andrés Illanes Albornoz 2b85d0
	else
e9fa07
		eval ${_rlc2_rlist_new}='${_rlc2_litem_new}';
Lucio Andrés Illanes Albornoz 2b85d0
	fi;
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
dbea96
#
dbea96
# rtl_lfilter() - remove item(s) from list
dbea96
# @_rlist:	inout reference to list
dbea96
# @_filter:	item(s) to remove
dbea96
# @[_sep]:	optional single non-zero, possibly multi-character, separator
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
Lucio Andrés Illanes Albornoz c6d6e0
rtl_lfilter() {
e9fa07
	rtl_lfilter2 "${1}" "${1}" "${2}" "${3:-}";
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
dbea96
#
dbea96
# rtl_lfilter2() - remove item(s) from list
dbea96
# @_rlist:	in reference to list
dbea96
# @_rlist_new:	out reference to new list
dbea96
# @_filter:	item(s) to remove
dbea96
# @[_sep]:	optional single non-zero, possibly multi-character, separator
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
Lucio Andrés Illanes Albornoz 3e5303
rtl_lfilter2() {
e9fa07
	local	_rlf2_rlist="${1#\$}" _rlf2_rlist_new="${2#\$}" _rlf2_filter="${3}" _rlf2_sep="${4:-}"\
e9fa07
		_rlf2_filterfl="" _rlf2_list="" _rlf2_litem="" _rlf2_litem_filter="" _rlf2_lnew="";
e9fa07
e9fa07
	if [ "${_rlf2_sep:+1}" = 1 ]; then
e9fa07
		local IFS="${_rlf2_sep}";
e9fa07
	else
e9fa07
		local _rlf2_sep=" " IFS="${RTL_IFS_ORIG}";
e9fa07
	fi;
e9fa07
e9fa07
	if [ "${_rlf2_filter:+1}" != 1 ]; then
6ea41b
		eval ${_rlf2_rlist_new}="\${${_rlf2_rlist}}";
e9fa07
	else
e9fa07
		eval _rlf2_list='${'"${_rlf2_rlist}"'}';
e9fa07
		eval ${_rlf2_rlist_new}=;
e9fa07
		for _rlf2_litem in ${_rlf2_list}; do
e9fa07
			_rlf2_filterfl=0;
e9fa07
			for _rlf2_litem_filter in ${_rlf2_filter}; do
e9fa07
				if [ "${_rlf2_litem_filter}" = "${_rlf2_litem}" ]; then
e9fa07
					_rlf2_filterfl=1; break;
Lucio Andrés Illanes Albornoz 3e5303
				fi;
Lucio Andrés Illanes Albornoz 3e5303
			done;
e9fa07
			if [ "${_rlf2_filterfl:-0}" -eq 0 ]; then
e9fa07
				eval ${_rlf2_rlist_new}='${'"${_rlf2_rlist_new}"':+${'"${_rlf2_rlist_new}"'}${_rlf2_sep}}${_rlf2_litem}';
Lucio Andrés Illanes Albornoz 3e5303
			fi;
Lucio Andrés Illanes Albornoz 3e5303
		done;
Lucio Andrés Illanes Albornoz 3e5303
	fi;
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
dbea96
#
dbea96
# rtl_lfirst() - obtain first (head) and remaining (tail) item(s) in list
dbea96
# @_rhead:	out reference to first item (head) in list, if any
dbea96
# @_rtail:	out reference to remaining items (tail) in list, if any
dbea96
# @_list:	list
dbea96
# @_sep:	single non-zero, possibly multi-character, separator
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
Lucio Andrés Illanes Albornoz 0875f5
rtl_lfirst() {
e9fa07
	local _rlf_rhead="${1#\$}" _rlf_rtail="${2#\$}" _rlf_list="${3}" _rlf_sep="${4}" IFS="${4}";
e9fa07
e9fa07
	set -- ${_rlf_list}; eval ${_rlf_rhead}='${1}';
Lucio Andrés Illanes Albornoz 0875f5
	if [ "${#}" -ge 0 ]; then
e9fa07
		shift; eval ${_rlf_rtail}=\"'${*}'\";
Lucio Andrés Illanes Albornoz 0875f5
	else
e9fa07
		eval ${_rlf_rtail}=;
Lucio Andrés Illanes Albornoz 0875f5
	fi;
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz 0875f5
};
Lucio Andrés Illanes Albornoz 0875f5
dbea96
#
dbea96
# rtl_lindexV() - retrieve item from list
dbea96
# @_rlout:	out reference to list item
dbea96
# @_idx:	zero-based (from start of list) or negative (from end of list) index of list item
dbea96
# @...:		list as positional parameters
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
e9fa07
rtl_lindexV() {
e9fa07
	local	_rliV_rlout="${1#\$}" _rliV_idx="${2}"	\
e9fa07
		_rliV_limit=0; shift 2;
e9fa07
e9fa07
	if [ "${_rliV_idx#-}" != "${_rliV_idx}" ]; then
e9fa07
		_rliV_idx="${_rliV_idx#-}";
e9fa07
		while [ "${#}" -gt "${_rliV_idx}" ]; do
e9fa07
			shift;
e9fa07
		done;
e9fa07
		_rliV_limit=$((${#} + 1));
e9fa07
	else
e9fa07
		_rliV_limit="${#}";
e9fa07
		shift "${_rliV_idx}";
e9fa07
	fi;
e9fa07
e9fa07
	if [ "${#}" -ge 1 ]\
e9fa07
	&& [ "${_rliV_idx}" -lt "${_rliV_limit}" ]; then
e9fa07
		eval ${_rliV_rlout}='${1}';
e9fa07
	else
e9fa07
		eval ${_rliV_rlout}=;
e9fa07
	fi;
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
dbea96
#
dbea96
# rtl_llength() - obtain count of items in list
dbea96
# @_rlen:	out reference to count of items in list
dbea96
# @_rlist:	in reference to list
dbea96
# @[_sep]:	optional single non-zero, possibly multi-character, separator
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
e9fa07
rtl_llength() {
e9fa07
	local _rll_rlen="${1#\$}" _rll_rlist="${2#\$}" _rll_sep="${3:- }" IFS="${3:-${IFS:- }}";
e9fa07
e9fa07
	eval set -- '${'"${_rll_rlist}"'}'\; ${_rll_rlen}='${#}';
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
dbea96
#
dbea96
# rtl_llift() - convert list w/ separator to new list w/ new separator
dbea96
# @_rlist:	inout reference to list
dbea96
# @_sep:	single non-zero, possibly multi-character, separator
dbea96
# @_sep_new:	single non-zero, possibly multi-character, separator of new list
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
Lucio Andrés Illanes Albornoz 974685
rtl_llift() {
e9fa07
	rtl_llift2 "${1}" "${1}" "${2}" "${3}";
Lucio Andrés Illanes Albornoz 974685
};
Lucio Andrés Illanes Albornoz 974685
dbea96
#
dbea96
# rtl_llift2() - convert list w/ separator to new list w/ new separator
dbea96
# @_rlist:	in reference to list
dbea96
# @_rlist_new:	out reference to new list
dbea96
# @_sep:	single non-zero, possibly multi-character, separator
dbea96
# @_sep_new:	single non-zero, possibly multi-character, separator of new list
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
Lucio Andrés Illanes Albornoz 3e5303
rtl_llift2() {
e9fa07
	local	_rl2_rlist="${1#\$}" _rl2_rlist_new="${2#\$}" _rl2_sep="${3:-}"	\
e9fa07
		_rl2_sep_new="${4}";
Lucio Andrés Illanes Albornoz 3e5303
e9fa07
	if [ "${_rl2_sep:+1}" = 1 ]; then
e9fa07
		local IFS="${_rl2_sep}";
e9fa07
	else
e9fa07
		local _rl2_sep=" " IFS="${RTL_IFS_ORIG}";
e9fa07
	fi;
Lucio Andrés Illanes Albornoz 3e5303
e9fa07
	eval set -- '${'"${_rl2_rlist}"'}'; IFS="${_rl2_sep_new}";
e9fa07
	eval ${_rl2_rlist_new}='"${*}"';
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
dbea96
#
dbea96
# rtl_lmatch() - check if item(s) in list
dbea96
# @_rlist:	in reference to list
dbea96
# @_item:	item(s) to search for
dbea96
# @[_sep]:	optional single non-zero, possibly multi-character, separator
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
Lucio Andrés Illanes Albornoz c6d6e0
rtl_lmatch() {
dbea96
	local	_rlm_rlist="${1#\$}" _rlm_item="${2}" _rlm_sep="${3:-}"	\
dbea96
		_rlm_list_="";
e9fa07
e9fa07
	rtl_lsearch2 "${_rlm_rlist}" \$_rlm_list_ "${_rlm_item}" "${_rlm_sep}";
e9fa07
	[ "${_rlm_list_:+1}" = 1 ];
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
dbea96
#
dbea96
# rtl_lmax() - obtain maximum length of items in list
dbea96
# @_rlist:	in reference to list
dbea96
# @_rmax:	out reference to maximum length of items variable
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
Lucio Andrés Illanes Albornoz b6a9a1
rtl_lmax() {
e9fa07
	local	_rlm2_rlist="${1#\$}" _rlm2_rmax="${2#\$}"	\
e9fa07
		_rlm2_len=0 _rlm2_len_max=0;
e9fa07
e9fa07
	eval set -- '${'"${_rlm2_rlist}"'}';
Lucio Andrés Illanes Albornoz b6a9a1
	while [ "${#}" -gt 0 ]; do
e9fa07
		_rlm2_len="${#1}";
e9fa07
		if [ "${_rlm2_len}" -gt "${_rlm2_len_max}" ]; then
e9fa07
			_rlm2_len_max="${_rlm2_len}";
Lucio Andrés Illanes Albornoz b6a9a1
		fi; shift;
e9fa07
	done;
e9fa07
	eval ${_rlm2_rmax}='${_rlm2_len_max}';
e9fa07
	return 0;
e9fa07
};
e9fa07
dbea96
#
dbea96
# rtl_lrangeV() - retrieve item(s) from list w/ range
dbea96
# @_rlout:	out reference to list item
dbea96
# @_idx0:	zero-based (from start of list) or negative (from end of list) start index of list item
dbea96
# @_idx1:	zero-based (from start of list) or negative (from end of list) end index of list item
dbea96
# @_sep:	single non-zero, possibly multi-character, separator
dbea96
# @...:		list as positional parameters
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
e9fa07
rtl_lrangeV() {
e9fa07
	local	_rlrV_rlout="${1#\$}" _rlrV_idx0="${2}" _rlrV_idx1="${3}" _rlrV_sep="${4}"	\
e9fa07
		_rlrV_limit=0; shift 4;
e9fa07
e9fa07
	if [ "${_rlrV_idx0#-}" != "${_rlrV_idx0}" ]; then
e9fa07
		eval ${_rlrV_rlout}=;
e9fa07
e9fa07
		return 1;
e9fa07
	elif [ "${_rlrV_idx1#-}" != "${_rlrV_idx1}" ]; then
e9fa07
		_rlrV_idx1="${_rlrV_idx1#-}";
e9fa07
e9fa07
		_rlrV_limit="${#}";
e9fa07
		shift "${_rlrV_idx0}";
e9fa07
e9fa07
		eval ${_rlrV_rlout}=;
e9fa07
		while [ "${#}" -gt 0 ]\
e9fa07
		   && [ "${_rlrV_idx1}" -lt "${#}" ];
e9fa07
		do
e9fa07
			eval ${_rlrV_rlout}='${'"${_rlrV_rlout}"':+${'"${_rlrV_rlout}"'}${_rlrV_sep}}${1}';
e9fa07
			shift;
e9fa07
		done;
e9fa07
e9fa07
		return 0;
e9fa07
	elif [ "${_rlrV_idx1}" -ge "${_rlrV_idx0}" ]; then
e9fa07
		_rlrV_limit="${#}";
e9fa07
		shift "${_rlrV_idx0}";
e9fa07
		: $((_rlrV_idx1 -= ${_rlrV_idx0}));
e9fa07
		: $((_rlrV_idx1 += 1));
e9fa07
e9fa07
		eval ${_rlrV_rlout}=;
e9fa07
		while [ "${_rlrV_idx1}" -gt 0 ]\
e9fa07
		   && [ "${#}" -gt 0 ];
e9fa07
		do
e9fa07
			eval ${_rlrV_rlout}='${'"${_rlrV_rlout}"':+${'"${_rlrV_rlout}"'}${_rlrV_sep}}${1}';
e9fa07
			: $((_rlrV_idx1 -= 1));
e9fa07
			shift;
e9fa07
		done;
e9fa07
e9fa07
		return 0;
e9fa07
	fi;
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
dbea96
#
dbea96
# rtl_lsearch() - obtains item(s) from list
dbea96
# @_rlist:	inout reference to list
dbea96
# @_filter:	item(s) to search for and include in new list
dbea96
# @[_sep]:	optional single non-zero, possibly multi-character, separator
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
Lucio Andrés Illanes Albornoz c6d6e0
rtl_lsearch() {
e9fa07
	rtl_lsearch2 "${1}" "${1}" "${2}" "${3:-}";
e9fa07
}
e9fa07
dbea96
#
dbea96
# rtl_lsearch2() - obtains item(s) from list
dbea96
# @_rlist:	in reference to list
dbea96
# @_rlist_new:	out reference to new list
dbea96
# @_filter:	item(s) to search for and include in new list
dbea96
# @[_sep]:	optional single non-zero, possibly multi-character, separator
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
e9fa07
rtl_lsearch2() {
e9fa07
	local	_rls2_rlist="${1#\$}" _rls2_rlist_new="${2#\$}"		\
e9fa07
		_rls2_filter="${3}" _rls2_sep="${4:-}"			\
e9fa07
		_rls2_list="" _rls2_litem="" _rls2_litem_filter=""	\
e9fa07
		_rls2_lnew="";
e9fa07
e9fa07
	if [ "${_rls2_sep:+1}" = 1 ]; then
e9fa07
		local IFS="${_rls2_sep}";
e9fa07
	else
e9fa07
		local _rls2_sep=" " IFS="${RTL_IFS_ORIG}";
e9fa07
	fi;
e9fa07
	if [ "${_rls2_filter:+1}" != 1 ]; then
e9fa07
		eval ${_rls2_rlist_new}='${_rls2_list}'; return 0;
e9fa07
	else
e9fa07
		eval _rls2_list='${'"${_rls2_rlist}"'}';
e9fa07
		for _rls2_litem in ${_rls2_list}; do
e9fa07
			for _rls2_litem_filter in ${_rls2_filter}; do
e9fa07
				if [ "${_rls2_litem_filter}" = "${_rls2_litem}" ]; then
e9fa07
					_rls2_lnew="${_rls2_lnew:+${_rls2_lnew}${_rls2_sep}}${_rls2_litem}";
e9fa07
					break;
e9fa07
				fi;
e9fa07
			done;
Lucio Andrés Illanes Albornoz 2b85d0
		done;
e9fa07
	fi;
e9fa07
e9fa07
	eval ${_rls2_rlist_new}='${_rls2_lnew}';
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
dbea96
#
dbea96
# rtl_lsearch_patternl() - obtain item(s) from list matching pattern
dbea96
# @_rlist:	inout reference to list
dbea96
# @_pattern:	pattern of item(s) to search for and include in list
dbea96
# @[_sep]:	optional single non-zero, possibly multi-character, separator
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
Lucio Andrés Illanes Albornoz b1d432
rtl_lsearch_patternl() {
e9fa07
	rtl_lsearch_patternl2 "${1}" "${1}" "${2}" "${3:-}";
e9fa07
};
e9fa07
dbea96
#
dbea96
# rtl_lsearch_patternl2() - obtain item(s) from list matching pattern
dbea96
# @_rlist:	in reference to list
dbea96
# @_rlist_new:	out reference to new list
dbea96
# @_pattern:	pattern of item(s) to search for and include in new list
dbea96
# @[_sep]:	optional single non-zero, possibly multi-character, separator
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
e9fa07
rtl_lsearch_patternl2() {
e9fa07
	local	_rlsp2_rlist="${1#\$}" _rlsp2_rlist_new="${2#\$}"	\
e9fa07
		_rlsp2_pattern="${3}" _rlsp2_sep="${4:- }"		\
e9fa07
		IFS="${4:-${IFS:- }}"					\
e9fa07
		_rlsp2_litem="" _rlsp2_lnew="";
e9fa07
e9fa07
	if [ "${_rlsp2_pattern:+1}" = 1 ]; then
e9fa07
		eval _rlsp2_list='${'"${_rlsp2_rlist}"'}';
e9fa07
		for _rlsp2_litem in ${_rlsp2_list}; do
e9fa07
			if [ "${_rlsp2_litem#${_rlsp2_pattern}}" != "${_rlsp2_litem}" ]; then
e9fa07
				_rlsp2_lnew="${_rlsp2_lnew:+${_rlsp2_lnew}${_rlsp2_sep}}${_rlsp2_litem}";
Lucio Andrés Illanes Albornoz b1d432
			fi;
Lucio Andrés Illanes Albornoz b1d432
		done;
Lucio Andrés Illanes Albornoz b1d432
	fi;
e9fa07
	eval ${_rlsp2_rlist_new}='${_rlsp2_lnew}';
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz b1d432
};
Lucio Andrés Illanes Albornoz b1d432
dbea96
#
dbea96
# rtl_lsortV() - sort list w/ sort(1)
dbea96
# @...:		list as positional parameters
dbea96
#
dbea96
# Returns:	zero (0) on success, non-zero (>0) on failure
dbea96
#
dbea96
rtl_lsortV() {
e9fa07
	printf "%s" "${*}" | tr " " "\n" | sort | paste -s -d " ";
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz 60fba6
};
Lucio Andrés Illanes Albornoz 60fba6
dbea96
#
dbea96
# rtl_lunfold_dependsV() - expand list into list w/ unfolded dependencies for each list item
dbea96
# @_vname_template:	template of variable names containing dependencies for each list item
dbea96
# @_rlist:		out reference to list w/ unfolded dependencies
dbea96
# @...:			list as positional parameters
dbea96
#
dbea96
# Returns:		zero (0) on success, non-zero (>0) on failure
dbea96
#
dbea96
RTL_LUNFOLD_DEPENDSV_LEVEL=0;
dbea96
rtl_lunfold_dependsV() {
e9fa07
	local	_rld_vname_template="${1}" _rld_rlist="${2#\$}"		\
e9fa07
		_rld_depends="" _rld_list="" _rld_name="" _rld_names=""	\
e9fa07
		_rld_vname_template_="";
e9fa07
		shift 2;
e9fa07
e9fa07
	for _rld_name in "${@}"; do
e9fa07
		eval _rld_vname_template_=\"${_rld_vname_template}\";
e9fa07
		if rtl_get_var_unsafe \$_rld_depends -u "${_rld_vname_template_}"\
e9fa07
		&& [ "${_rld_depends:+1}" = 1 ]; then
dbea96
			: $((RTL_LUNFOLD_DEPENDSV_LEVEL+=1));
dbea96
			eval _rld_depends${RTL_LUNFOLD_DEPENDSV_LEVEL}='${_rld_depends}';
dbea96
			rtl_lunfold_dependsV "${_rld_vname_template}" \$_rld_depends${RTL_LUNFOLD_DEPENDSV_LEVEL} ${_rld_depends};
dbea96
			eval _rld_depends='${_rld_depends'"${RTL_LUNFOLD_DEPENDSV_LEVEL}"'}';
dbea96
			unset '_rld_depends'"${RTL_LUNFOLD_DEPENDSV_LEVEL}";
dbea96
			: $((RTL_LUNFOLD_DEPENDSV_LEVEL-=1));
e9fa07
			rtl_lconcat \$_rld_names "${_rld_depends}";
Lucio Andrés Illanes Albornoz 763157
		fi;
e9fa07
		rtl_lconcat \$_rld_names "${_rld_name}";
Lucio Andrés Illanes Albornoz 763157
	done;
e9fa07
	eval ${_rld_rlist}='${_rld_names}';
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz 763157
};
Lucio Andrés Illanes Albornoz 763157
64844b
# vim:filetype=sh textwidth=0