#
# set +o errexit -o noglob is assumed.
#
ex_rtl_lconcat() {
local _list="${1}" _litem_new="${2}" _sep="${3:- }" IFS="${3:-${IFS}}";
if [ -n "${_list}" ]; then
printf "%s%s%s" "${_list}" "${_sep}" "${_litem_new}";
else
printf "%s" "${_litem_new}";
fi;
};
ex_rtl_lfilter() {
local _list="${1}" _filter="${2}" _sep="${3:- }" IFS="${3:-${IFS}}" \
_filterfl="" _litem="" _litem_filter="" _lnew="";
if [ -z "${_filter}" ]; then
echo "${_list}"; return 0;
else for _litem in ${_list}; do
_filterfl=0;
for _litem_filter in ${_filter}; do
if [ "${_litem_filter}" = "${_litem}" ]; then
_filterfl=1; break;
fi;
done;
if [ "${_filterfl:-0}" -eq 0 ]; then
_lnew="${_lnew:+${_lnew}${_sep}}${_litem}";
fi;
done; fi;
echo "${_lnew}";
};
ex_rtl_llength() {
local _list="${1}" _sep="${2:- }" IFS="${2:-${IFS}}" _litem="" _llength=0;
for _litem in ${_list}; do
: $((_llength+=1));
done;
echo "${_llength}";
};
ex_rtl_lmatch() {
local _list="${1}" _item="${2}" _sep="${3}";
[ -n "$(ex_rtl_lsearch "${_list}" "${_item}" "${_sep}")" ];
};
ex_rtl_lsearch() {
local _list="${1}" _filter="${2}" _sep="${3:- }" IFS="${3:-${IFS}}" \
_litem="" _litem_filter="" _lnew="";
if [ -z "${_filter}" ]; then
echo "${_list}"; return 0;
else for _litem in ${_list}; do
for _litem_filter in ${_filter}; do
if [ "${_litem_filter}" = "${_litem}" ]; then
_lnew="${_lnew:+${_lnew}${_sep}}${_litem}";
break;
fi;
done;
done; fi;
echo "${_lnew}";
};
# vim:filetype=sh