|
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 |
2b85d0 |
ex_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 |
2b85d0 |
ex_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 |
2b85d0 |
ex_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 |
2b85d0 |
ex_rtl_lmatch() {
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
local _list="${1}" _item="${2}" _sep="${3}";
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
[ -n "$(ex_rtl_lsearch "${_list}" "${_item}" "${_sep}")" ];
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
};
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
ex_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 |
2b85d0 |
# vim:filetype=sh
|