Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
RTLP_INSTALL_NL="
Lucio Andrés Illanes Albornoz 14fe23
";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
# XXX optimise
Lucio Andrés Illanes Albornoz 14fe23
# implement %<...{...,...}...>
Lucio Andrés Illanes Albornoz 14fe23
# support multiple %<...*...> in same spec
Lucio Andrés Illanes Albornoz 14fe23
# split_ = unfold_
Lucio Andrés Illanes Albornoz 14fe23
# impl 3/ 1## 1# 1%% 1%
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# DSL functor implementation
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_fmap($_rparams, $_prefix, $_spec, $_fn, [$_param[...], --, [$_spec[...]]])
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_fmap() {
Lucio Andrés Illanes Albornoz 14fe23
	local	_rif_rparams="${1#\$}" _rif_prefix="${2}" _rif_spec="${3}"	\
Lucio Andrés Illanes Albornoz 14fe23
		_rif_fn="${4}" _rif_IFS0="${IFS:- 	}" _rif_paramsc=0	\
Lucio Andrés Illanes Albornoz 14fe23
		_rif_spec_cur="" _rif_spec_list="" _rif_spec0="" _rif_specsc=0	\
Lucio Andrés Illanes Albornoz 14fe23
		_rif_nspec=0 _rif_rc=0 IFS; shift 4;
Lucio Andrés Illanes Albornoz 14fe23
	while [ "${#}" -gt 0 ] && [ "x${1}" != "x--" ]; do
Lucio Andrés Illanes Albornoz 14fe23
		: $((_rif_paramsc+=1)); local "${_rif_rparams}${_rif_paramsc}=${1}"; shift;
Lucio Andrés Illanes Albornoz 14fe23
	done; shift;
Lucio Andrés Illanes Albornoz 14fe23
	while [ "${#}" -gt 0 ] && [ "x${1}" != "x--" ]; do
Lucio Andrés Illanes Albornoz 14fe23
		: $((_rif_specsc+=1)); local "_rif_specs${_rif_specsc}=${1}"; shift;
Lucio Andrés Illanes Albornoz 14fe23
	done;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	if rtlp_install_fmap_params "${_rif_rparams}" \$_rif_spec ""\
Lucio Andrés Illanes Albornoz 611492
	&& rtlp_install_fmap_patterns "${_rif_rparams}" "${_rif_prefix}" "${_rif_spec}" \$_rif_spec_list; then
Lucio Andrés Illanes Albornoz 14fe23
		IFS="${RTLP_INSTALL_NL}"; for _rif_spec_cur in ${_rif_spec_list}; do
Lucio Andrés Illanes Albornoz 14fe23
			IFS="${_rif_IFS0}"; set --;
Lucio Andrés Illanes Albornoz 14fe23
			_rif_nspec=1; while [ "${_rif_nspec}" -le "${_rif_specsc}" ]; do
Lucio Andrés Illanes Albornoz 14fe23
				eval _rif_spec0=\"\${_rif_specs${_rif_nspec}}\";
Lucio Andrés Illanes Albornoz 14fe23
				rtlp_install_fmap_params			\
Lucio Andrés Illanes Albornoz 14fe23
					"${_rif_rparams}"			\
Lucio Andrés Illanes Albornoz 14fe23
					\$_rif_spec0 "${_rif_spec_cur}";
Lucio Andrés Illanes Albornoz 14fe23
				eval set -- '"${@}"' '"${_rif_spec0}"'; : $((_rif_nspec+=1));
Lucio Andrés Illanes Albornoz 14fe23
			done;
Lucio Andrés Illanes Albornoz 14fe23
			eval "${_rif_fn}" \"\$\{@\}\"; _rif_rc=$((${?} ? ${?} : ${_rif_rc}));
Lucio Andrés Illanes Albornoz 14fe23
			[ "${_rif_rc}" -ne 0 ] && break;
Lucio Andrés Illanes Albornoz 14fe23
		done; IFS="${_rif_IFS0}";
Lucio Andrés Illanes Albornoz 14fe23
	else
Lucio Andrés Illanes Albornoz 14fe23
		_rif_rc=1;
Lucio Andrés Illanes Albornoz 14fe23
	fi;
Lucio Andrés Illanes Albornoz 14fe23
	return "${_rif_rc}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_fmap_params($_rparams, $_rspec, $_item)
Lucio Andrés Illanes Albornoz 14fe23
RTLP_INSTALL_FMAP_PARAMS_LEVEL=0;
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_fmap_params() {
Lucio Andrés Illanes Albornoz 14fe23
	local	_rifp_rparams="${1#\$}" _rifp_rspec="${2#\$}" _rifp_item="${3}"		\
Lucio Andrés Illanes Albornoz 14fe23
		_rifp_expr="" _rifp_expr_="" _rifp_expr_sub="" _rifp_expr_op=""		\
Lucio Andrés Illanes Albornoz 14fe23
		_rifp_lhs="" _rifp_rc=0 _rifp_rhs="" _rifp_subexpr=""; _status="";
Lucio Andrés Illanes Albornoz 14fe23
	eval _rifp_lhs='${'"${_rifp_rspec}"'}'\; ${_rifp_rspec}=;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	while true; do
Lucio Andrés Illanes Albornoz 14fe23
		if ! rtlp_install_splitl_ref \$_rifp_expr \$_rifp_lhs \$_rifp_rhs '%[' ']'; then
Lucio Andrés Illanes Albornoz 14fe23
			eval ${_rifp_rspec}='${'"${_rifp_rspec}"'}${_rifp_lhs}'; break;
Lucio Andrés Illanes Albornoz 14fe23
		else case "${_rifp_expr}" in
Lucio Andrés Illanes Albornoz 14fe23
		[0-9]*)
Lucio Andrés Illanes Albornoz 14fe23
			eval _rifp_expr='${'"${_rifp_rparams}${_rifp_expr}"'}'; ;;
Lucio Andrés Illanes Albornoz 14fe23
		@[0-9]*)
Lucio Andrés Illanes Albornoz 14fe23
			: $((RTLP_INSTALL_FMAP_PARAMS_LEVEL+=1));
Lucio Andrés Illanes Albornoz 14fe23
			eval _rifp_expr${RTLP_INSTALL_FMAP_PARAMS_LEVEL}='${'"${_rifp_rparams}${_rifp_expr#@}"'}';
Lucio Andrés Illanes Albornoz 14fe23
			rtlp_install_fmap_params "${_rifp_rparams}"			\
Lucio Andrés Illanes Albornoz 14fe23
					\$_rifp_expr${RTLP_INSTALL_FMAP_PARAMS_LEVEL}	\
Lucio Andrés Illanes Albornoz 14fe23
					"${_rifp_item}"; _rifp_rc="${?}";
Lucio Andrés Illanes Albornoz 14fe23
			eval _rifp_expr='${_rifp_expr'"${RTLP_INSTALL_FMAP_PARAMS_LEVEL}"'}';
Lucio Andrés Illanes Albornoz 14fe23
			: $((RTLP_INSTALL_FMAP_PARAMS_LEVEL-=1));
Lucio Andrés Illanes Albornoz 14fe23
			[ "${_rifp_rc}" -eq 1 ] && break; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		[_0-9a-zA-Z]*)
Lucio Andrés Illanes Albornoz 14fe23
			case "${_rifp_expr}" in
Lucio Andrés Illanes Albornoz 14fe23
			DNAME*)	_rifp_subexpr="${_rifp_expr#DNAME}"; _rifp_expr="${_rifp_item%/*}"; ;;
Lucio Andrés Illanes Albornoz 14fe23
			FNAME*)	_rifp_subexpr="${_rifp_expr#FNAME}"; _rifp_expr="${_rifp_item##*/}"; ;;
Lucio Andrés Illanes Albornoz 14fe23
			ITEM*)	_rifp_subexpr="${_rifp_expr#ITEM}"; _rifp_expr="${_rifp_item}"; ;;
Lucio Andrés Illanes Albornoz 14fe23
			"")	_rifp_rc=1; _status="zero-length parameter name in expression"; ;;
Lucio Andrés Illanes Albornoz 14fe23
			*)
Lucio Andrés Illanes Albornoz 7f5fb5
				_rifp_expr_="${_rifp_expr%%[!_0-9a-zA-Z]*}";
Lucio Andrés Illanes Albornoz 14fe23
				_rifp_subexpr="${_rifp_expr#${_rifp_expr_}}";
Lucio Andrés Illanes Albornoz 14fe23
				_rifp_expr="${_rifp_expr_}";
Lucio Andrés Illanes Albornoz 14fe23
				if eval [ '"${'"${_rifp_rparams}${_rifp_expr}"':+1}"' = 1 ]; then
Lucio Andrés Illanes Albornoz 14fe23
					eval _rifp_expr='${'"${_rifp_rparams}${_rifp_expr}"'}';
Lucio Andrés Illanes Albornoz 14fe23
				else	_rifp_rc=1; _status="unknown parameter name \`${_rifp_expr}' in expression";
Lucio Andrés Illanes Albornoz 14fe23
				fi; ;;
Lucio Andrés Illanes Albornoz 14fe23
			esac;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
			if [ "${_rifp_rc}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz 14fe23
				while true; do
Lucio Andrés Illanes Albornoz 14fe23
					if ! rtlp_install_splitl_subexpr		\
Lucio Andrés Illanes Albornoz 14fe23
							\$_rifp_subexpr_		\
Lucio Andrés Illanes Albornoz 14fe23
							\$_rifp_subexpr			\
Lucio Andrés Illanes Albornoz 14fe23
							'## # %% %'; then
Lucio Andrés Illanes Albornoz 14fe23
						break;
Lucio Andrés Illanes Albornoz 14fe23
					else case "${_rifp_subexpr_}" in
Lucio Andrés Illanes Albornoz 14fe23
					/*)	;;
Lucio Andrés Illanes Albornoz 14fe23
					\#\#*)	_rifp_expr="${_rifp_expr##${_rifp_subexpr_#\#\#}}"; ;;
Lucio Andrés Illanes Albornoz 14fe23
					\#*)	_rifp_expr="${_rifp_expr#${_rifp_subexpr_#\#}}"; ;;
Lucio Andrés Illanes Albornoz 14fe23
					%%*)	_rifp_expr="${_rifp_expr%%${_rifp_subexpr_#%%}}"; ;;
Lucio Andrés Illanes Albornoz 14fe23
					%*)	_rifp_expr="${_rifp_expr%${_rifp_subexpr_#%}}"; ;;
Lucio Andrés Illanes Albornoz 14fe23
					"")	_rifp_rc=1; _status="zero-length subexpression in expression"; ;;
Lucio Andrés Illanes Albornoz 14fe23
					*)	_rifp_rc=1; _status="invalid subexpression \`${_rifp_subexpr_}' in expression"; ;;
Lucio Andrés Illanes Albornoz 14fe23
					esac; fi;
Lucio Andrés Illanes Albornoz 14fe23
				done;
Lucio Andrés Illanes Albornoz 14fe23
			fi; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		"")	_rifp_rc=1; _status="zero-length expression"; break; ;;
Lucio Andrés Illanes Albornoz 14fe23
		*)	_rifp_rc=1; _status="invalid expression \`${_rifp_expr}'"; break; ;;
Lucio Andrés Illanes Albornoz 14fe23
		esac; fi;
Lucio Andrés Illanes Albornoz 14fe23
		eval ${_rifp_rspec}='${'"${_rifp_rspec}"'}${_rifp_lhs}${_rifp_expr}'; _rifp_lhs="${_rifp_rhs}";
Lucio Andrés Illanes Albornoz 14fe23
	done; return "${_rifp_rc}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_fmap_patterns($_rparams, $_prefix, $_spec, $_rspec_list)
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_fmap_patterns() {
Lucio Andrés Illanes Albornoz 14fe23
	local	_rifp2_rparams="${1#\$}" _rifp2_prefix="${2}" _rifp2_spec="${3}"	\
Lucio Andrés Illanes Albornoz 14fe23
		_rifp2_rspec_list="${4#\$}" _rifp2_expr="" _rifp2_lhs="" _rifp2_rc=0	\
Lucio Andrés Illanes Albornoz 14fe23
		_rifp2_rhs="" IFS="${RTLP_INSTALL_NL}"; _status="";
Lucio Andrés Illanes Albornoz 14fe23
	_rifp2_lhs="${_rifp2_spec}";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	while true; do
Lucio Andrés Illanes Albornoz 14fe23
		if rtlp_install_splitl_ref \$_rifp2_expr \$_rifp2_lhs \$_rifp2_rhs '%<' '>'; then
Lucio Andrés Illanes Albornoz 14fe23
			case "${_rifp2_expr}" in
Lucio Andrés Illanes Albornoz 14fe23
			*\**)
Lucio Andrés Illanes Albornoz 4025bd
				if [ "${_rifp2_lhs#/}" = "${_rifp2_lhs}" ]; then
Lucio Andrés Illanes Albornoz 4025bd
					_rifp2_lhs_full="${_rifp2_prefix:+${_rifp2_prefix%}/}${_rifp2_lhs:+${_rifp2_lhs%/}/}";
Lucio Andrés Illanes Albornoz 4025bd
				else
Lucio Andrés Illanes Albornoz 4025bd
					_rifp2_lhs_full="${_rifp2_lhs:+${_rifp2_lhs%/}/}";
Lucio Andrés Illanes Albornoz 4025bd
				fi;
Lucio Andrés Illanes Albornoz 4025bd
				set +o noglob; for _rifp2_pname in ${_rifp2_lhs_full}${_rifp2_expr}; do
Lucio Andrés Illanes Albornoz 14fe23
					set -o noglob; _rifp2_pname="${_rifp2_pname%/}${_rifp2_rhs:+/${_rifp2_rhs}}";
Lucio Andrés Illanes Albornoz 14fe23
					if [ -e "${_rifp2_pname}" ]; then
Lucio Andrés Illanes Albornoz 14fe23
						eval ${_rifp2_rspec_list}='${'"${_rifp2_rspec_list}"':+${'"${_rifp2_rspec_list}"'}${RTLP_INSTALL_NL}}${_rifp2_pname}';
Lucio Andrés Illanes Albornoz 14fe23
					fi;
Lucio Andrés Illanes Albornoz 14fe23
				done; set -o noglob; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
			"")	_rifp2_rc=1; _status="zero-length pattern"; break; ;;
Lucio Andrés Illanes Albornoz 14fe23
			*)	_rifp2_rc=1; _status="invalid pattern \`${_rifp2_expr}'"; break; ;;
Lucio Andrés Illanes Albornoz 14fe23
			esac; _rifp2_lhs="${_rifp2_rhs}";
Lucio Andrés Illanes Albornoz 14fe23
		else
Lucio Andrés Illanes Albornoz 14fe23
			eval ${_rifp2_rspec_list}='${'"${_rifp2_rspec_list}"':+${'"${_rifp2_rspec_list}"'}${RTLP_INSTALL_NL}}${_rifp2_lhs}';
Lucio Andrés Illanes Albornoz 14fe23
			break;
Lucio Andrés Illanes Albornoz 14fe23
		fi;
Lucio Andrés Illanes Albornoz 14fe23
	done; return "${_rifp2_rc}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# Install OPeration functions
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_op_chmod($_nflag, $_prefix, $_vflag, $_fname, $_mode)
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_op_chmod() {
Lucio Andrés Illanes Albornoz 14fe23
	local _rioc_nflag="${1}" _rioc_prefix="${2}" _rioc_vflag="${3}" _rioc_fname="${4}" _rioc_mode="${5}";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_rioc_fname "${_rioc_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_rc "${_rioc_nflag}" "${_rioc_vflag}" rtl_fileop chmod "${_rioc_mode}" "${_rioc_fname}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_op_chgrp($_nflag, $_prefix, $_vflag, $_fname, $_group)
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_op_chgrp() {
Lucio Andrés Illanes Albornoz 14fe23
	local _rioc2_nflag="${1}" _rioc2_prefix="${2}" _rioc2_vflag="${3}" _rioc2_fname="${4}" _rioc2_group="${5}";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_rioc2_fname "${_rioc2_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_rc "${_rioc2_nflag}" "${_rioc2_vflag}" rtl_fileop chgrp "${_rioc2_group}" "${_rioc2_fname}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_op_chown($_nflag, $_prefix, $_vflag, $_fname, $_owner)
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_op_chown() {
Lucio Andrés Illanes Albornoz 14fe23
	local _rioc3_nflag="${1}" _rioc3_prefix="${2}" _rioc3_vflag="${3}" _rioc3_fname="${4}" _rioc3_owner="${5}";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_rioc3_fname "${_rioc3_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_rc "${_rioc3_nflag}" "${_rioc3_vflag}" rtl_fileop chown "${_rioc3_owner}" "${_rioc3_fname}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_op_cp($_nflag, $_prefix, $_vflag, $_file_fname_dst, $_file_fname_src)
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_op_cp() {
Lucio Andrés Illanes Albornoz 14fe23
	local _rioc4_nflag="${1}" _rioc4_prefix="${2}" _rioc4_vflag="${3}" _rioc4_fname_dst="${4}" _rioc4_fname_src="${5}";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_rioc4_fname_dst "${_rioc4_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_rioc4_fname_src "${_rioc4_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_rc "${_rioc4_nflag}" "${_rioc4_vflag}" rtl_fileop cp "${_rioc4_fname_src}" "${_rioc4_fname_dst}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_op_cp_follow_if_newer($_nflag, $_prefix, $_vflag, $_file_fname_dst, $_file_fname_src)
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_op_cp_follow_if_newer() {
Lucio Andrés Illanes Albornoz 14fe23
	local _riocfin_nflag="${1}" _riocfin_prefix="${2}" _riocfin_vflag="${3}" _riocfin_fname_dst="${4}" _riocfin_fname_src="${5}";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_riocfin_fname_dst "${_riocfin_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_riocfin_fname_src "${_riocfin_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	if [ -e "${_riocfin_fname_dst}" ]\
Lucio Andrés Illanes Albornoz 14fe23
	&& rtl_is_newer "${_riocfin_fname_src}" "${_riocfin_fname_dst}"; then
Lucio Andrés Illanes Albornoz 14fe23
		return 0;
Lucio Andrés Illanes Albornoz 14fe23
	else
Lucio Andrés Illanes Albornoz 14fe23
		rtlp_install_rc "${_riocfin_nflag}" "${_riocfin_vflag}" rtl_fileop cp_follow "${_riocfin_fname_src}" "${_riocfin_fname_dst}";
Lucio Andrés Illanes Albornoz 14fe23
	fi;
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_op_ln_symbolic($_nflag, $_prefix, $_vflag, $_ln_fname, $_ln_target)
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_op_ln_symbolic() {
Lucio Andrés Illanes Albornoz 14fe23
	local _riols_nflag="${1}" _riols_prefix="${2}" _riols_vflag="${3}" _riols_ln_fname="${4}" _riols_ln_target="${5}";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_riols_ln_fname "${_riols_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	if [ -e "${_riols_ln_fname}" ]; then
Lucio Andrés Illanes Albornoz 14fe23
		rtlp_install_rc "${_riols_nflag}" "${_riols_vflag}" rtl_fileop rm "${_riols_ln_fname}";
Lucio Andrés Illanes Albornoz 14fe23
	fi;
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_rc "${_riols_nflag}" "${_riols_vflag}" rtl_fileop ln_symbolic "${_riols_ln_target}" "${_riols_ln_fname}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_op_mkdir($_nflag, $_prefix, $_vflag, $_dname)
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_op_mkdir() {
Lucio Andrés Illanes Albornoz 14fe23
	local _riom_nflag="${1}" _riom_prefix="${2}" _riom_vflag="${3}" _riom_dname="${4}";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_riom_dname "${_riom_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_rc "${_riom_nflag}" "${_riom_vflag}" rtl_fileop mkdir "${_riom_dname}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_op_mv($_nflag, $_prefix, $_vflag, $_file_fname_dst, $_file_fname_src)
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_op_mv() {
Lucio Andrés Illanes Albornoz 14fe23
	local _riom2_nflag="${1}" _riom2_prefix="${2}" _riom2_vflag="${3}" _riom2_fname_dst="${4}" _riom2_fname_src="${5}";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_riom2_fname_dst "${_riom2_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_riom2_fname_src "${_riom2_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_rc "${_riom2_nflag}" "${_riom2_vflag}" rtl_fileop mv "${_riom2_fname_src}" "${_riom2_fname_dst}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_op_rm($_nflag, $_prefix, $_vflag, $_pname)
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_op_rm() {
Lucio Andrés Illanes Albornoz 14fe23
	local _rior_nflag="${1}" _rior_prefix="${2}" _rior_vflag="${3}" _rior_pname="${4}";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_rior_pname "${_rior_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_rc "${_rior_nflag}" "${_rior_vflag}" rtl_fileop rm "${_rior_pname}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_op_touch($_nflag, $_prefix, $_vflag, $_fname, $_ts)
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_op_touch() {
Lucio Andrés Illanes Albornoz 14fe23
	local _riot_nflag="${1}" _riot_prefix="${2}" _riot_vflag="${3}" _riot_fname="${4}" _riot_ts="${5:-}";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_fixup_fname \$_riot_fname "${_riot_prefix}";
Lucio Andrés Illanes Albornoz 14fe23
	rtlp_install_rc "${_riot_nflag}" "${_riot_vflag}" rtl_fileop touch "${_riot_fname}" "${_riot_ts}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# Ancillary functions
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_fixup_fname($_rfname, $_prefix)
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_fixup_fname() {
Lucio Andrés Illanes Albornoz 14fe23
	local _riff_rfname="${1#\$}" __riff_prefix="${2}" _riff_fname="";
Lucio Andrés Illanes Albornoz 14fe23
	eval _riff_fname='${'"${_riff_rfname}"'}';
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	if [ "${_riff_fname#/}" = "${_riff_fname}" ]; then
Lucio Andrés Illanes Albornoz 14fe23
		eval ${_riff_rfname}='${__riff_prefix:+${__riff_prefix}/}${_riff_fname}';
Lucio Andrés Illanes Albornoz 14fe23
	fi;
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_rc($_nflag, $_vflag, $_fn, [...])
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_rc() {
Lucio Andrés Illanes Albornoz 14fe23
	local _rir_nflag="${1}" _rir_vflag="${2}" _rir_fn="${3}" _rir_rc=0; shift 3;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	if [ "${_rir_nflag}" -eq 1 ]\
Lucio Andrés Illanes Albornoz 14fe23
	|| [ "${_rir_vflag}" -gt 0 ]; then
Lucio Andrés Illanes Albornoz dc07ba
		rtl_log_msg "install" "${MSG_rtl_install_v2_rc}" "${_rir_fn}${_rir_fn:+ ${*}}";
Lucio Andrés Illanes Albornoz 14fe23
	fi;
Lucio Andrés Illanes Albornoz 14fe23
	if [ "${_rir_nflag}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz 14fe23
		"${_rir_fn}" "${@}"; _rir_rc="${?}";
Lucio Andrés Illanes Albornoz 14fe23
	fi;
Lucio Andrés Illanes Albornoz 14fe23
	return "${_rir_rc}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_splitl($_rlhs, $_rrhs, $_sep)
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# rtlp_install_splitl()
Lucio Andrés Illanes Albornoz 14fe23
# Slit @_rlhs from left-hand side into left-hand and right-hand side
Lucio Andrés Illanes Albornoz 14fe23
# according to @_sep w/ backslash escaping
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# @_rlhs:		inout reference to string and left-hand side result
Lucio Andrés Illanes Albornoz 14fe23
# @_rrhs:		out reference to right-hand side result
Lucio Andrés Illanes Albornoz 14fe23
# @_sep:		single non-zero, possibly multi-character, separator
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# Calling convention:	inout ref. @_rlhs, out ref. @_rrhs
Lucio Andrés Illanes Albornoz 14fe23
# Notate bene:		@_sep is a shell pattern
Lucio Andrés Illanes Albornoz 14fe23
# Returns:		zero (0) on success, non-zero (>0) on absence of unescaped @_sep in @_rlhs
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_splitl() {
Lucio Andrés Illanes Albornoz 14fe23
	local	_ris_rlhs="${1#\$}" _ris_rrhs="${2#\$}" _ris_sep="${3}" _ris_lhs=""	\
Lucio Andrés Illanes Albornoz 14fe23
		_ris_lhs_new="" _ris_rc=1 _ris_rhs="" _ris_rhs_new="";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	eval _ris_rhs='${'"${_ris_rlhs}"'}';
Lucio Andrés Illanes Albornoz 14fe23
	while [ "${_ris_rhs:+1}" = 1 ]; do
Lucio Andrés Illanes Albornoz 14fe23
		_ris_lhs_new="${_ris_rhs%%${_ris_sep}*}";
Lucio Andrés Illanes Albornoz 14fe23
		if [ "${_ris_lhs_new}" != "${_ris_rhs}" ]; then
Lucio Andrés Illanes Albornoz 14fe23
			_ris_rhs_new="${_ris_rhs#*${_ris_sep}}";
Lucio Andrés Illanes Albornoz 14fe23
			if [ "${_ris_lhs_new%\\}" = "${_ris_lhs_new}" ]; then
Lucio Andrés Illanes Albornoz 14fe23
				eval	${_ris_rlhs}='${_ris_lhs}${_ris_lhs_new}'	\
Lucio Andrés Illanes Albornoz 14fe23
					${_ris_rrhs}='${_ris_rhs_new}'; _ris_rc=0; break;
Lucio Andrés Illanes Albornoz 14fe23
			else
Lucio Andrés Illanes Albornoz 14fe23
				_ris_lhs="${_ris_lhs}${_ris_lhs_new%\\}${_ris_sep}";
Lucio Andrés Illanes Albornoz 14fe23
				_ris_rhs="${_ris_rhs_new}";
Lucio Andrés Illanes Albornoz 14fe23
			fi;
Lucio Andrés Illanes Albornoz 14fe23
		else break; fi;
Lucio Andrés Illanes Albornoz 14fe23
	done; return "${_ris_rc}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_splitl_ref($_ritem, $_rlhs, $_rrhs, $_sepl, $_sepr)
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# rtlp_install_splitl_ref()
Lucio Andrés Illanes Albornoz 14fe23
# Split @_rlhs from left-hand side into left-hand, reference, and
Lucio Andrés Illanes Albornoz 14fe23
# right-hand side according to left-hand (beginning) and right-hand
Lucio Andrés Illanes Albornoz 14fe23
# (ending) side separators w/ backslash escaping
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# @_rref:		out reference to reference
Lucio Andrés Illanes Albornoz 14fe23
# @_rlhs:		inout reference to string and left-hand side result
Lucio Andrés Illanes Albornoz 14fe23
# @_rrhs:		out reference to right-hand side result
Lucio Andrés Illanes Albornoz 14fe23
# @_sepl:		single non-zero, possibly multi-character, left-hand side separator
Lucio Andrés Illanes Albornoz 14fe23
# @_sepr:		single non-zero, possibly multi-character, right-hand side separator
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# Calling convention:	out ref. @_rref, inout ref. @_rlhs, out ref. @_rrhs
Lucio Andrés Illanes Albornoz 14fe23
# Notate bene:		@_sepl and @_sepr are shell patterns
Lucio Andrés Illanes Albornoz 14fe23
# Returns:		zero (0) on success, non-zero (>0) on absence of unescaped references in @_rlhs
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_splitl_ref() {
Lucio Andrés Illanes Albornoz 14fe23
	local	_risr_rref="${1#\$}" _risr_rlhs="${2#\$}" _risr_rrhs="${3#\$}" _risr_sepl="${4}"	\
Lucio Andrés Illanes Albornoz 14fe23
		_risr_sepr="${5}" _risr_item="" _risr_item_lhs="" _risr_item_lhs_new=""			\
Lucio Andrés Illanes Albornoz 14fe23
		_risr_item_rhs="" _risr_item_rhs_new="" _risr_lhs="" _risr_lhs_new="" _risr_rc=1	\
Lucio Andrés Illanes Albornoz 14fe23
		_risr_rhs="" _risr_rhs_new="";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	eval _risr_rhs='${'"${_risr_rlhs}"'}';
Lucio Andrés Illanes Albornoz 14fe23
	while [ "${_risr_rhs:+1}" = 1 ]; do
Lucio Andrés Illanes Albornoz 14fe23
		_risr_lhs_new="${_risr_rhs%%${_risr_sepl}*}";
Lucio Andrés Illanes Albornoz 14fe23
		if [ "${_risr_lhs_new}" != "${_risr_rhs}" ]; then
Lucio Andrés Illanes Albornoz 14fe23
			_risr_rhs_new="${_risr_rhs#*${_risr_sepl}}";
Lucio Andrés Illanes Albornoz 14fe23
			if [ "${_risr_lhs_new%\\}" = "${_risr_lhs_new}" ]; then
Lucio Andrés Illanes Albornoz 14fe23
				_risr_item=""; _risr_item_lhs=""; _risr_item_rhs="${_risr_rhs_new}";
Lucio Andrés Illanes Albornoz 14fe23
				while [ "${_risr_item_rhs:+1}" = 1 ]; do
Lucio Andrés Illanes Albornoz 14fe23
					_risr_item_lhs_new="${_risr_item_rhs%%${_risr_sepr}*}";
Lucio Andrés Illanes Albornoz 14fe23
					if [ "${_risr_item_lhs_new}" != "${_risr_item_rhs}" ]; then
Lucio Andrés Illanes Albornoz 14fe23
						_risr_item_rhs_new="${_risr_item_rhs#*${_risr_sepr}}";
Lucio Andrés Illanes Albornoz 14fe23
						if [ "${_risr_item_lhs_new%\\}" = "${_risr_item_lhs_new}" ]; then
Lucio Andrés Illanes Albornoz 14fe23
							_risr_item="${_risr_item_lhs}${_risr_item_lhs_new}";
Lucio Andrés Illanes Albornoz 14fe23
							_risr_item_rhs="${_risr_item_rhs_new}";
Lucio Andrés Illanes Albornoz 14fe23
							_risr_rc=0; break;
Lucio Andrés Illanes Albornoz 14fe23
						else
Lucio Andrés Illanes Albornoz 14fe23
							_risr_item_lhs="${_risr_item_lhs}${_risr_item_lhs_new%\\}${_risr_sepr}";
Lucio Andrés Illanes Albornoz 14fe23
							_risr_item_rhs="${_risr_item_rhs_new}";
Lucio Andrés Illanes Albornoz 14fe23
						fi;
Lucio Andrés Illanes Albornoz 14fe23
					else break; fi;
Lucio Andrés Illanes Albornoz 14fe23
				done; break;
Lucio Andrés Illanes Albornoz 14fe23
			else
Lucio Andrés Illanes Albornoz 14fe23
				_risr_lhs="${_risr_lhs}${_risr_lhs_new%\\}${_risr_sepl}"; _risr_rhs="${_risr_rhs_new}";
Lucio Andrés Illanes Albornoz 14fe23
			fi;
Lucio Andrés Illanes Albornoz 14fe23
		else break; fi;
Lucio Andrés Illanes Albornoz 14fe23
	done;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	eval	${_risr_rref}='${_risr_item}'								\
Lucio Andrés Illanes Albornoz 14fe23
		${_risr_rlhs}='${_risr_lhs}${_risr_lhs_new}'						\
Lucio Andrés Illanes Albornoz 14fe23
		${_risr_rrhs}='${_risr_item_rhs}';
Lucio Andrés Illanes Albornoz 14fe23
	return "${_risr_rc}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
# {{{ rtlp_install_splitl_subexpr($_rexpr, $_rlhs, $_lsep)
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# rtlp_install_splitl_subexpr()
Lucio Andrés Illanes Albornoz 14fe23
# Split @_rlhs from left-hand side into left-hand (subexpression) and right-hand
Lucio Andrés Illanes Albornoz 14fe23
# side according to list of expression operator prefixes w/ backslash escaping
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# @_rexpr:		out reference to right-hand (expression) side result
Lucio Andrés Illanes Albornoz 14fe23
# @_rlhs:		inout reference to string and left-hand side result
Lucio Andrés Illanes Albornoz 14fe23
# @_lsep:		non-zero SP-separated list of non-zero, possibly multi-character, expression operator prefixes
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
# Calling convention:	out ref. @_rexpr, inout ref. @_rlhs
Lucio Andrés Illanes Albornoz 14fe23
# Notate bene:		@_lsep list items are shell patterns
Lucio Andrés Illanes Albornoz 14fe23
# Returns:		zero (0) on success, non-zero (>0) on absence of unescaped expressions in @_rlhs
Lucio Andrés Illanes Albornoz 14fe23
#
Lucio Andrés Illanes Albornoz 14fe23
rtlp_install_splitl_subexpr() {
Lucio Andrés Illanes Albornoz 14fe23
	local	_riss_rexpr="${1#\$}" _riss_rlhs="${2#\$}" _riss_lsep="${3}" _riss_lhs=""		\
Lucio Andrés Illanes Albornoz 14fe23
		_riss_matchfl="" _riss_nsep="" _riss_rc=1 _riss_sep="" _riss_sexpr=""			\
Lucio Andrés Illanes Albornoz 14fe23
		_riss_sexpr_lhs="" _riss_sexpr_lhs_new="" _riss_sexpr_rhs=""				\
Lucio Andrés Illanes Albornoz 14fe23
		_riss_sexpr_rhs_new="" _riss_sexpr_rhs_new_min="" _riss_sexpr_rhs_new_min_new=""	\
Lucio Andrés Illanes Albornoz 14fe23
		_riss_sexpr_sep="" _riss_sexpr_sep_new=""
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	eval _riss_lhs='${'"${_riss_rlhs}"'}'; set -- ${_riss_lsep};
Lucio Andrés Illanes Albornoz 14fe23
	if [ "${_riss_lhs:+1}" = 1 ]; then
Lucio Andrés Illanes Albornoz 14fe23
		_riss_matchfl=0; _riss_nsep=1; while [ "${_riss_nsep}" -le "${#}" ]; do
Lucio Andrés Illanes Albornoz 14fe23
			eval _riss_sep='${'"${_riss_nsep}"'}';
Lucio Andrés Illanes Albornoz 14fe23
			case "${_riss_lhs}" in
Lucio Andrés Illanes Albornoz 14fe23
			${_riss_sep}*)	_riss_matchfl=1; break; ;;
Lucio Andrés Illanes Albornoz 14fe23
			*)		: $((_riss_nsep+=1)); ;;
Lucio Andrés Illanes Albornoz 14fe23
			esac;
Lucio Andrés Illanes Albornoz 14fe23
		done;
Lucio Andrés Illanes Albornoz 14fe23
		if [ "${_riss_matchfl}" -eq 1 ]; then
Lucio Andrés Illanes Albornoz 14fe23
			_riss_sexpr=""; _riss_sexpr_lhs="${_riss_sep}";
Lucio Andrés Illanes Albornoz 14fe23
			_riss_sexpr_rhs="${_riss_lhs#${_riss_sep}}";
Lucio Andrés Illanes Albornoz 14fe23
			while [ "${_riss_sexpr_rhs:+1}" = 1 ]; do
Lucio Andrés Illanes Albornoz 14fe23
				_riss_sexpr_rhs_new_min=-1; _riss_sexpr_sep=""; _riss_nsep=1;
Lucio Andrés Illanes Albornoz 14fe23
				while [ "${_riss_nsep}" -le "${#}" ]; do
Lucio Andrés Illanes Albornoz 14fe23
					eval _riss_sexpr_sep_new='${'"${_riss_nsep}"'}';
Lucio Andrés Illanes Albornoz 14fe23
					_riss_sexpr_rhs_new="${_riss_sexpr_rhs%%${_riss_sexpr_sep_new}*}";
Lucio Andrés Illanes Albornoz 14fe23
					if [ "${_riss_sexpr_rhs_new}" != "${_riss_sexpr_rhs}" ]; then
Lucio Andrés Illanes Albornoz 14fe23
						_riss_sexpr_rhs_new_min_new="${#_riss_sexpr_rhs_new}";
Lucio Andrés Illanes Albornoz 14fe23
						if [ "${_riss_sexpr_rhs_new_min_new}" -le "${_riss_sexpr_rhs_new_min}" ]\
Lucio Andrés Illanes Albornoz 14fe23
						|| [ "${_riss_sexpr_rhs_new_min}" -eq -1 ]; then
Lucio Andrés Illanes Albornoz 14fe23
							_riss_sexpr_rhs_new_min="${_riss_sexpr_rhs_new_min_new}";
Lucio Andrés Illanes Albornoz 14fe23
							_riss_sexpr_sep="${_riss_sexpr_sep_new}";
Lucio Andrés Illanes Albornoz 14fe23
						fi;
Lucio Andrés Illanes Albornoz 14fe23
					fi; : $((_riss_nsep+=1));
Lucio Andrés Illanes Albornoz 14fe23
				done;
Lucio Andrés Illanes Albornoz 14fe23
				if [ "${_riss_sexpr_sep:+1}" = 1 ]; then
Lucio Andrés Illanes Albornoz 14fe23
					_riss_sexpr_lhs_new="${_riss_sexpr_rhs%%${_riss_sexpr_sep}*}";
Lucio Andrés Illanes Albornoz 14fe23
					if [ "${_riss_sexpr_lhs_new%\\}" = "${_riss_sexpr_lhs_new}" ]; then
Lucio Andrés Illanes Albornoz 14fe23
						_riss_sexpr_lhs="${_riss_sexpr_lhs}${_riss_sexpr_lhs_new}";
Lucio Andrés Illanes Albornoz 14fe23
						_riss_sexpr_rhs="${_riss_sexpr_sep}${_riss_sexpr_rhs#*${_riss_sexpr_sep}}"; break;
Lucio Andrés Illanes Albornoz 14fe23
					else
Lucio Andrés Illanes Albornoz 14fe23
						_riss_sexpr_lhs="${_riss_sexpr_lhs}${_riss_sexpr_rhs%%\\${_riss_sexpr_sep}*}${_riss_sexpr_sep}";
Lucio Andrés Illanes Albornoz 14fe23
						_riss_sexpr_rhs="${_riss_sexpr_rhs#*\\${_riss_sexpr_sep}}";
Lucio Andrés Illanes Albornoz 14fe23
					fi;
Lucio Andrés Illanes Albornoz 14fe23
				else
Lucio Andrés Illanes Albornoz 14fe23
					_riss_sexpr_lhs="${_riss_sexpr_lhs}${_riss_sexpr_rhs}"; _riss_sexpr_rhs=""; break;
Lucio Andrés Illanes Albornoz 14fe23
				fi;
Lucio Andrés Illanes Albornoz 14fe23
			done;
Lucio Andrés Illanes Albornoz 14fe23
			eval ${_riss_rexpr}='${_riss_sexpr_lhs}' ${_riss_rlhs}='${_riss_sexpr_rhs}'; _riss_rc=0;
Lucio Andrés Illanes Albornoz 14fe23
		fi;
Lucio Andrés Illanes Albornoz 14fe23
	fi; return "${_riss_rc}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
# }}}
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
rtl_install_v2() {
Lucio Andrés Illanes Albornoz 14fe23
	local	_ri_prefix="" _ri_spec_flag="" _ri_spec_list="" _ri_iflag=0 _ri_IFS="${IFS:- 	}"	\
Lucio Andrés Illanes Albornoz 14fe23
		_ri_nflag=0 _ri_paramsc=0 _ri_vflag=0 _ri_IFS0 _ri_nparam=0 _ri_opt="" _ri_param=""	\
Lucio Andrés Illanes Albornoz 14fe23
		_ri_rc=0 _ri_spec="" _ri_spec_dst="" _ri_spec_src="" IFS OPTARG="" OPTIND=1; _status="";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	while true; do
Lucio Andrés Illanes Albornoz 14fe23
		if [ "${1:-}" = "--" ]; then
Lucio Andrés Illanes Albornoz 14fe23
			: $((OPTIND+=1)); break;
Lucio Andrés Illanes Albornoz 14fe23
		elif ! getopts hiI:np:v _ri_opt; then
Lucio Andrés Illanes Albornoz 14fe23
			break;
Lucio Andrés Illanes Albornoz 14fe23
		else case "${_ri_opt}" in
Lucio Andrés Illanes Albornoz 14fe23
		h)	printf "usage: rtl_install [-i] [-I ifs] [-n] [-p name=val] [-v] prefix spec_list\n" >&2;
Lucio Andrés Illanes Albornoz 14fe23
			printf "       -i...........: continue on soft errors\n" >&2;
Lucio Andrés Illanes Albornoz 14fe23
			printf "       -I ifs.......: process spec_list with ifs instead of NL\n" >&2;
Lucio Andrés Illanes Albornoz 14fe23
			printf "       -n...........: perform dry run\n" >&2;
Lucio Andrés Illanes Albornoz 14fe23
			printf "       -p name=val..: set named parameter\n" >&2;
Lucio Andrés Illanes Albornoz 14fe23
			printf "       -v...........: increase verbosity\n" >&2;
Lucio Andrés Illanes Albornoz 14fe23
			printf "       prefix.......: pathname prefix\n" >&2;
Lucio Andrés Illanes Albornoz 14fe23
			printf "       spec_list....: ifs-separated list of specs\n" >&2; return 1; ;;
Lucio Andrés Illanes Albornoz 14fe23
		i)	_ri_iflag=1; ;;
Lucio Andrés Illanes Albornoz 14fe23
		I)	_ri_IFS="${OPTARG}"; ;;
Lucio Andrés Illanes Albornoz 14fe23
		n)	_ri_nflag=1; ;;
Lucio Andrés Illanes Albornoz 14fe23
		p)	: $((_ri_paramsc+=1)); local _ri_params${OPTARG%%=*}="${OPTARG#*=}"; ;;
Lucio Andrés Illanes Albornoz 14fe23
		v)	: $((_ri_vflag+=1)); ;;
Lucio Andrés Illanes Albornoz 14fe23
		*)	return 1; ;;
Lucio Andrés Illanes Albornoz 14fe23
		esac; fi;
Lucio Andrés Illanes Albornoz 14fe23
	done; shift $((${OPTIND}-1));
Lucio Andrés Illanes Albornoz 14fe23
	_ri_prefix="${1:-}"; _ri_spec_list="${2:-}"; shift 2;
Lucio Andrés Illanes Albornoz cf5471
	_ri_IFS0="${IFS:- 	}"; IFS="${_ri_IFS}"; set -- ${_ri_spec_list}; IFS="${_ri_IFS0}";
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz 14fe23
		_ri_spec_src="${1}";
Lucio Andrés Illanes Albornoz 14fe23
		case "${_ri_spec_src}" in
Lucio Andrés Illanes Albornoz 14fe23
		\?*)	_ri_spec_flag="?"; ;;
Lucio Andrés Illanes Albornoz 14fe23
		*)	_ri_spec_flag=""; ;;
Lucio Andrés Illanes Albornoz 14fe23
		esac;
Lucio Andrés Illanes Albornoz 14fe23
		if ! rtlp_install_splitl \$_ri_spec_src \$_ri_spec_dst "="; then
Lucio Andrés Illanes Albornoz 14fe23
			_ri_rc=1; _status="zero-length or invalid specification \`${1}'";
Lucio Andrés Illanes Albornoz 14fe23
		else case "${_ri_spec_src}" in
Lucio Andrés Illanes Albornoz 14fe23
		-)
Lucio Andrés Illanes Albornoz 14fe23
			rtlp_install_fmap \$_ri_params "${_ri_prefix}" "${_ri_spec_dst}"		\
Lucio Andrés Illanes Albornoz 14fe23
				rtlp_install_op_rm "${_ri_nflag}" "${_ri_prefix}" "${_ri_vflag}"	\
Lucio Andrés Illanes Albornoz 14fe23
					""								\
Lucio Andrés Illanes Albornoz 14fe23
					-- "%[1]" "%[2]" "%[3]" "%[ITEM]"; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		/)
Lucio Andrés Illanes Albornoz 14fe23
			rtlp_install_fmap \$_ri_params "${_ri_prefix}" "${_ri_spec_dst}"		\
Lucio Andrés Illanes Albornoz 14fe23
				rtlp_install_op_mkdir "${_ri_nflag}" "${_ri_prefix}" "${_ri_vflag}"	\
Lucio Andrés Illanes Albornoz 14fe23
					""								\
Lucio Andrés Illanes Albornoz 14fe23
				       	-- "%[1]" "%[2]" "%[3]" "%[ITEM]"; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		t*)
Lucio Andrés Illanes Albornoz 14fe23
			rtlp_install_fmap \$_ri_params "${_ri_prefix}" "${_ri_spec_dst}"		\
Lucio Andrés Illanes Albornoz 14fe23
				rtlp_install_op_touch "${_ri_nflag}" "${_ri_prefix}" "${_ri_vflag}"	\
Lucio Andrés Illanes Albornoz 14fe23
					"" "" 								\
Lucio Andrés Illanes Albornoz 14fe23
					-- "%[1]" "%[2]" "%[3]" "%[ITEM]" "%[5]"; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		:*)
Lucio Andrés Illanes Albornoz 14fe23
			rtlp_install_fmap \$_ri_params "${_ri_prefix}" "${_ri_spec_src#:}"		\
Lucio Andrés Illanes Albornoz 14fe23
				rtlp_install_op_cp "${_ri_nflag}" "${_ri_prefix}" "${_ri_vflag}"	\
Lucio Andrés Illanes Albornoz 14fe23
					"${_ri_spec_dst}" ""						\
Lucio Andrés Illanes Albornoz 14fe23
					-- "%[1]" "%[2]" "%[3]" "%[@4]" "%[ITEM]"; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		!*)
Lucio Andrés Illanes Albornoz 14fe23
			rtlp_install_fmap \$_ri_params "${_ri_prefix}" "${_ri_spec_src#!}"		\
Lucio Andrés Illanes Albornoz 14fe23
				rtlp_install_op_mv "${_ri_nflag}" "${_ri_prefix}" "${_ri_vflag}"	\
Lucio Andrés Illanes Albornoz 14fe23
					"${_ri_spec_dst}" ""						\
Lucio Andrés Illanes Albornoz 14fe23
					--  "%[1]" "%[2]" "%[3]" "%[@4]" "%[ITEM]"; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		@*)
Lucio Andrés Illanes Albornoz 14fe23
			rtlp_install_fmap \$_ri_params "${_ri_prefix}" "${_ri_spec_dst}"		\
Lucio Andrés Illanes Albornoz 14fe23
				rtlp_install_op_ln_symbolic "${_ri_nflag}" "${_ri_prefix}"		\
Lucio Andrés Illanes Albornoz 14fe23
					"${_ri_vflag}" "" "${_ri_spec_src#@}" ""			\
Lucio Andrés Illanes Albornoz 14fe23
					-- "%[1]" "%[2]" "%[3]" "%[ITEM]" "%[@5]"; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		+*)
Lucio Andrés Illanes Albornoz 14fe23
			rtlp_install_fmap \$_ri_params "${_ri_prefix}" "${_ri_spec_src#+}"		\
Lucio Andrés Illanes Albornoz 14fe23
				rtlp_install_op_cp_follow_if_newer "${_ri_nflag}" "${_ri_prefix}"	\
Lucio Andrés Illanes Albornoz 14fe23
					"${_ri_vflag}" "${_ri_spec_dst}" ""				\
Lucio Andrés Illanes Albornoz 14fe23
					-- "%[1]" "%[2]" "%[3]" "%[@4]" "%[ITEM]"; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		g*)
Lucio Andrés Illanes Albornoz 14fe23
			rtlp_install_fmap \$_ri_params "${_ri_prefix}" "${_ri_spec_dst}"		\
Lucio Andrés Illanes Albornoz 14fe23
				rtlp_install_op_chgrp "${_ri_nflag}" "${_ri_prefix}" "${_ri_vflag}"	\
Lucio Andrés Illanes Albornoz 14fe23
					"" "${_ri_spec_src#g}" 						\
Lucio Andrés Illanes Albornoz 14fe23
					-- "%[1]" "%[2]" "%[3]" "%[ITEM]" "%[5]"; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		m[0-7][0-7][0-7][0-7])
Lucio Andrés Illanes Albornoz 14fe23
			rtlp_install_fmap \$_ri_params "${_ri_prefix}" "${_ri_spec_dst}"		\
Lucio Andrés Illanes Albornoz 14fe23
				rtlp_install_op_chmod "${_ri_nflag}" "${_ri_prefix}" "${_ri_vflag}"	\
Lucio Andrés Illanes Albornoz 14fe23
					"" "${_ri_spec_src#m}"						\
Lucio Andrés Illanes Albornoz 14fe23
					-- "%[1]" "%[2]" "%[3]" "%[ITEM]" "%[5]"; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		o*)
Lucio Andrés Illanes Albornoz 14fe23
			rtlp_install_fmap \$_ri_params "${_ri_prefix}" "${_ri_spec_dst}"		\
Lucio Andrés Illanes Albornoz 14fe23
				rtlp_install_op_chown "${_ri_nflag}" "${_ri_prefix}" "${_ri_vflag}"	\
Lucio Andrés Illanes Albornoz 14fe23
					"" "${_ri_spec_src#o}" 						\
Lucio Andrés Illanes Albornoz 14fe23
					-- "%[1]" "%[2]" "%[3]" "%[ITEM]" "%[5]"; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		T*)
Lucio Andrés Illanes Albornoz 14fe23
			rtlp_install_fmap \$_ri_params "${_ri_prefix}" "${_ri_spec_dst}"		\
Lucio Andrés Illanes Albornoz 14fe23
				rtlp_install_op_touch "${_ri_nflag}" "${_ri_prefix}" "${_ri_vflag}"	\
Lucio Andrés Illanes Albornoz 14fe23
					"" "${_ri_spec_src#T}" 						\
Lucio Andrés Illanes Albornoz 14fe23
					-- "%[1]" "%[2]" "%[3]" "%[ITEM]" "%[5]"; ;;
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
		\#*|"")
Lucio Andrés Illanes Albornoz 14fe23
			;;
Lucio Andrés Illanes Albornoz 14fe23
		esac; _ri_rc="${?}"; fi;
Lucio Andrés Illanes Albornoz 14fe23
		shift;
Lucio Andrés Illanes Albornoz 14fe23
		if [ "${_ri_rc}" -ne 0 ]\
Lucio Andrés Illanes Albornoz 14fe23
		&& [ "${_ri_iflag}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz 14fe23
			break;
Lucio Andrés Illanes Albornoz 14fe23
		fi;
Lucio Andrés Illanes Albornoz 14fe23
	done;
Lucio Andrés Illanes Albornoz 14fe23
	return "${_ri_rc}";
Lucio Andrés Illanes Albornoz 14fe23
};
Lucio Andrés Illanes Albornoz 14fe23
Lucio Andrés Illanes Albornoz 14fe23
# vim:filetype=sh