|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0185bc |
# set -o noglob is assumed.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
EXP_RTL_IFS="${IFS}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_basename() { echo "${1##*/}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_date() { command date "+${1:-${DEFAULT_TIMESTAMP_FMT}}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_dirname() { echo "${1%/*}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_get_var_unsafe() { eval echo \${${1}}; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_pop_IFS() { IFS="${EXP_RTL_IFS}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_push_IFS() { EXP_RTL_IFS="${IFS}"; IFS="${1}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bb98b3 |
ex_rtl_try_run() { if ex_rtl_test_cmd "${1}"; then "${@}"; fi; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_set_var_unsafe() { [ -n "${2}" ] && eval ${1}=\"${2}\" || return 0; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_test_cmd() { command -v "${1}" >/dev/null; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_toupper() { echo "${1}" | tr a-z A-Z; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_unset_vars() { while [ ${#} -gt 0 ]; do unset "${1}"; shift; done; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_lfilter() {
|
|
Lucio Andrés Illanes Albornoz |
907bd3 |
local _list="${1}" _filter="${2}" _lnew="" _litem="" _litem_filter="";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
if [ -z "${_filter}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
echo "${_list}"; return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
else for _litem in ${_list}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
for _litem_filter in ${_filter}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
if [ "${_litem_filter}" = "${_litem}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
_lnew="${_lnew:+${_lnew} }${_litem}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
break;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
done; fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
echo "${_lnew}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_lfilter_not() {
|
|
Lucio Andrés Illanes Albornoz |
907bd3 |
local _list="${1}" _filter="${2}" _lnew="" _litem="" _litem_filter="" _filterfl="";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
if [ -z "${_filter}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
echo "${_list}"; return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
else for _litem in ${_list}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
_filterfl=0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
for _litem_filter in ${_filter}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
if [ "${_litem_filter}" = "${_litem}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
_filterfl=1; break;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
if [ "${_filterfl:-0}" -eq 0 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
_lnew="${_lnew:+${_lnew} }${_litem}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1de702 |
done; fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
echo "${_lnew}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_lmatch() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
local _cmp="${3}" IFS="${2}"; set -- ${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
if [ "${1}" = "${_cmp}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
fi; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
done; return 1;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_run_cmd_unsplit() {
|
|
Lucio Andrés Illanes Albornoz |
907bd3 |
local _cmd="${1}" _cmdline="" _rc="" IFS; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
[ -n "${1}" ] &&\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
_cmdline="${_cmdline:+${_cmdline}:}${1}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
IFS=:; ${_cmd} ${_cmdline}; _rc=$?;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
return ${_rc};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_set_vars() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
local _vname_dst="${1}" _vname_src_tmpls="${2}" \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_vars_set_vname="${3}" _vname_src _vars_set_tmp="" \
|
|
Lucio Andrés Illanes Albornoz |
907bd3 |
_vars_set_old="";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
for _vname_src in ${_vname_src_tmpls}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_vname_src="${_vname_src}_${_vname_dst}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_vval_src="$(ex_rtl_get_var_unsafe "${_vname_src}")";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ -n "${_vval_src}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_set_var_unsafe "PKG_${_vname_dst}" "${_vval_src}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_vars_set_tmp="${_vars_set_tmp:+${_vars_set_tmp} }PKG_${_vname_dst}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_vars_set_old="$(ex_rtl_get_var_unsafe "${_vars_set_vname}")";
|
|
Lucio Andrés Illanes Albornoz |
907bd3 |
ex_rtl_set_var_unsafe "${_vars_set_vname}" \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
"${_vars_set_old:+${_vars_set_old} }${_vars_set_tmp}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
32ad21 |
# vim:filetype=sh
|