|
Lucio Andrés Illanes Albornoz |
2b85d0 |
#
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
# set +o errexit -o noglob 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 |
2b85d0 |
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 |
2b85d0 |
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 |
2b85d0 |
echo "${_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 |
2b85d0 |
echo "${_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 |
2b85d0 |
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 |
2b85d0 |
echo "${_llength}";
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
};
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
rtl_lmatch() {
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
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 |
c6d6e0 |
rtl_lsearch() {
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
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 |
2b85d0 |
echo "${_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 |
2b85d0 |
echo "${_lnew}";
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
};
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
|
|
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 |
763157 |
echo "${_names}";
|
|
Lucio Andrés Illanes Albornoz |
763157 |
};
|
|
Lucio Andrés Illanes Albornoz |
763157 |
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
# vim:filetype=sh
|