From b1d432e5fcdabfe5e5bbded8961eb7dfba48a5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Thu, 26 Aug 2021 19:03:25 +0200 Subject: Implements logging tags, tag sets, and themes. subr/pkgtool_init.subr:pkgtoolp_init_args(): set ${BUILD_HNAME}. --- subr.rtl/rtl_fileop.subr | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'subr.rtl/rtl_fileop.subr') diff --git a/subr.rtl/rtl_fileop.subr b/subr.rtl/rtl_fileop.subr index d69cead7..4addffcd 100644 --- a/subr.rtl/rtl_fileop.subr +++ b/subr.rtl/rtl_fileop.subr @@ -3,10 +3,8 @@ # # -# Private globals and subroutines +# Private subroutines # -RTLP_FILEOP_LOG=0; -rtl_fileop_set_log() { RTLP_FILEOP_LOG="${1}"; }; rtlp_fileop_check() { local _prefix="${1}" _pname="" _rname=""; shift; @@ -16,38 +14,38 @@ rtlp_fileop_check() { }; rtlp_fileop_log() { - local _msg="${1}"; - if [ "${RTLP_FILEOP_LOG:-0}" -eq 1 ]; then - rtl_log_msg notice "${_msg}"; - fi; + rtl_log_msg "fileop" "${1}"; }; +# +# Public subroutines +# rtl_fileop() { local _op="${1}" _dst="" _group="" _install_args="" _mode="" _owner="" _rc=0 _src=""; shift; case "${_op}" in cd) if [ \( -z "${1}" \) -o ! \( -L "${1}" -o -e "${1}" \) ]; then - rtl_log_msg fatalexit "Invalid or non-existent directory \`%s'." "${1}"; + rtl_log_msg "fatalexit" "Error: Invalid or non-existent directory \`%s'." "${1}"; elif rtlp_fileop_check "${PREFIX:-}" "${1}"; then rtlp_fileop_log "Changing working directory to \`${1}'."; cd -- "${1}"; _rc="${?}"; fi; ;; chmod) if [ "${#}" -lt 2 ]; then - rtl_log_msg fatalexit "Missing parameters (in: chmod %s.)" "${*}"; + rtl_log_msg "fatalexit" "Error: Missing parameters (in: chmod %s.)" "${*}"; elif _mode="${1}" && shift\ && rtlp_fileop_check "${PREFIX:-}" "${*}"; then rtlp_fileop_log "Changing file mode bits of \`${*}' to \`${_mode}'."; chmod -- "${_mode}" "${@}"; _rc="${?}"; fi; ;; chgrp) if [ "${#}" -lt 2 ]; then - rtl_log_msg fatalexit "Missing parameters (in: chgrp %s.)" "${*}"; + rtl_log_msg "fatalexit" "Error: Missing parameters (in: chgrp %s.)" "${*}"; elif _group="${1}" && shift\ && rtlp_fileop_check "${PREFIX:-}" "${*}"; then rtlp_fileop_log "Changing file group of \`${*}' to \`${_group}'."; chgrp -- "${_group}" "${@}"; _rc="${?}"; fi; ;; chown) if [ "${#}" -lt 2 ]; then - rtl_log_msg fatalexit "Missing parameters (in: chown %s.)" "${*}"; + rtl_log_msg "fatalexit" "Error: Missing parameters (in: chown %s.)" "${*}"; elif _owner="${1}" && shift\ && rtlp_fileop_check "${PREFIX:-}" "${*}"; then rtlp_fileop_log "Changing file owner of \`${*}' to \`${_owner}'."; @@ -55,7 +53,7 @@ rtl_fileop() { fi; ;; cp_follow) if [ "${#}" -lt 2 ]; then - rtl_log_msg fatalexit "Missing parameters (in: cp_follow %s}.)" "${*}"; + rtl_log_msg "fatalexit" "Error: Missing parameters (in: cp_follow %s}.)" "${*}"; elif rtlp_fileop_check "${PREFIX:-}" "${*}"; then _src="${*}"; _src="${_src% *}"; _dst="${*}"; _dst="${_dst##* }"; @@ -63,7 +61,7 @@ rtl_fileop() { cp -pLR -- "${@}"; _rc="${?}"; fi; ;; cp) if [ "${#}" -lt 2 ]; then - rtl_log_msg fatalexit "Missing parameters (in: cp %s.)" "${*}"; + rtl_log_msg "fatalexit" "Error: Missing parameters (in: cp %s.)" "${*}"; elif rtlp_fileop_check "${PREFIX:-}" "${*}"; then _src="${*}"; _src="${_src% *}"; _dst="${*}"; _dst="${_dst##* }"; @@ -72,7 +70,7 @@ rtl_fileop() { fi; ;; install) if [ "${#}" -lt 2 ]; then - rtl_log_msg fatalexit "Missing parameters (in: install %s.)" "${*}"; + rtl_log_msg "fatalexit" "Error: Missing parameters (in: install %s.)" "${*}"; else _dst="$(while [ ""${#}"" -gt 2 ]; do shift; done; printf "%s" "${2}")"; _install_args="$(while [ ""${#}"" -gt 2 ]; do printf "%s" "${1}"; shift; done)"; _src="$(while [ ""${#}"" -gt 2 ]; do shift; done; printf "%s" "${1}")"; @@ -83,7 +81,7 @@ rtl_fileop() { fi; ;; ln_symbolic) if [ \( -z "${1}" \) -o \( -z "${2}" \) ]; then - rtl_log_msg fatalexit "Missing parameters (in: ln_symbolic %s.)" "${*}"; + rtl_log_msg "fatalexit" "Error: Missing parameters (in: ln_symbolic %s.)" "${*}"; elif rtlp_fileop_check "${PREFIX:-}" "${2}"; then if rtl_fileop test "${2}"; then rtl_fileop rm "${2}"; @@ -94,13 +92,13 @@ rtl_fileop() { fi; fi; ;; mv) if [ \( -z "${1}" \) -o \( -z "${2}" \) ]; then - rtl_log_msg fatalexit "Missing parameters (in: mv %s.)" "${*}"; + rtl_log_msg "fatalexit" "Error: Missing parameters (in: mv %s.)" "${*}"; elif rtlp_fileop_check "${PREFIX:-}" "${1}" "${2}"; then rtlp_fileop_log "Moving \`${1}' to \`${2}' w/ -fs"; mv -f -- "${1}" "${2}"; _rc="${?}"; fi; ;; touch) if [ -z "${1}" ]; then - rtl_log_msg fatalexit "Missing parameters (in: touch %s.)" "${*}"; + rtl_log_msg "fatalexit" "Error: Missing parameters (in: touch %s.)" "${*}"; elif rtlp_fileop_check "${PREFIX:-}" "${1}"; then rtlp_fileop_log "Touching file \`${1}'${2:+ w/ timestamp \`${2}\'}."; touch ${2:+-t "${2}"} -- "${1}"; _rc="${?}"; @@ -108,7 +106,7 @@ rtl_fileop() { mkdir|mkfifo|rm|source|source_opt|test) while [ \( "${?}" -eq 0 \) -a \( ""${#}"" -gt 0 \) ]; do if [ -z "${1}" ]; then - rtl_log_msg fatalexit "Missing parameters (in: %s %s.)" "${_op}" "${*}"; + rtl_log_msg "fatalexit" "Error: Missing parameters (in: %s %s.)" "${_op}" "${*}"; elif [ "${_op}" = mkdir ]\ && [ ! -d "${1}" ]\ && rtlp_fileop_check "${PREFIX:-}" "${1}"; then @@ -145,7 +143,7 @@ rtl_fileop() { return 1; fi; shift; done; ;; - *) rtl_log_msg fatalexit "Error: rtl_fileop() called w/ invalid parameter(s): %s" "${*}"; ;; + *) rtl_log_msg "fatalexit" "Error: rtl_fileop() called w/ invalid parameter(s): %s" "${*}"; ;; esac; return "${_rc}"; }; -- cgit v1.2.3