From 51fbc32b57527b389ba533db097d0522ec04744c Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz (arab, vxp) Date: Feb 05 2017 22:36:57 +0000 Subject: build.sh, {subr,vars}/*: general cleanup. --- diff --git a/build.sh b/build.sh index a6cfeff..fa07ff6 100755 --- a/build.sh +++ b/build.sh @@ -74,14 +74,14 @@ for BUILD_TARGET_LC in $(subst_tgts invariants ${BUILD_TARGETS_META:-world}); do always) _pkg_step_cmds="pkg_${1%:*}"; ;; main) if [ -n "${BUILD_PACKAGES_RESTART}" ]; then if [ -z "${ARG_RESTART_AT}" ]\ - || match_list "${ARG_RESTART_AT}" , "${1%:*}"; then + || lmatch "${ARG_RESTART_AT}" , "${1%:*}"; then _pkg_step_cmds="pkg_${PKG_NAME}_${1%:*} pkg_${1%:*}"; fi; elif ! is_build_script_done ${PKG_NAME} ${1%:*}; then _pkg_step_cmds="pkg_${PKG_NAME}_${1%:*} pkg_${1%:*}"; fi; ;; optional) - if match_list "${ARG_RESTART_AT}" "," "${1%:*}"; then + if lmatch "${ARG_RESTART_AT}" "," "${1%:*}"; then _pkg_step_cmds="pkg_${PKG_NAME}_${1%:*} pkg_${1%:*}"; fi; ;; esac; diff --git a/subr/build.subr b/subr/build.subr index 1341e97..afd7607 100644 --- a/subr/build.subr +++ b/subr/build.subr @@ -108,6 +108,15 @@ lfilter() { echo ${_lnew}; }; +lmatch() { + local _cmp="${3}"; push_IFS "${2}"; set -- ${1}; pop_IFS; + while [ ${#} -gt 0 ]; do + if [ "${1}" = "${_cmp}" ]; then + return 0; + fi; shift; + done; return 1; +}; + log_env_vars() { local _nvar _arg _arg_len_max; log_msg info "Variables for this ${1:-build}:"; shift; @@ -148,15 +157,6 @@ log_msg() { fi; [ ${_lvl} = failexit ] && exit 1 || return 0; }; -match_list() { - local _cmp="${3}"; push_IFS "${2}"; set -- ${1}; pop_IFS; - while [ ${#} -gt 0 ]; do - if [ "${1}" = "${_cmp}" ]; then - return 0; - fi; shift; - done; return 1; -}; - run_cmd_unsplit() { local _cmd="${1}" _cmdline _rc; shift; while [ ${#} -gt 0 ]; do diff --git a/subr/mode_check_updates.subr b/subr/mode_check_updates.subr index 51cf707..56423a5 100644 --- a/subr/mode_check_updates.subr +++ b/subr/mode_check_updates.subr @@ -54,7 +54,7 @@ mode_check_pkg_updates() { cu_url="$(get_var_unsafe PKG_${cu_NAME}_URL)"; cu_url_type="$(get_var_unsafe PKG_${cu_NAME}_URL_TYPE)"; . vars/check_updates.vars; - if match_list "${CHECK_UPDATES_SKIP}" " " "${cu_name}"; then + if lmatch "${CHECK_UPDATES_SKIP}" " " "${cu_name}"; then log_msg vnfo "Skipping \`${cu_name}' (set in \${CHECK_UPDATES_SKIP}.)"; return 0; elif [ "${cu_url_type}" = "git" ]; then diff --git a/subr/pre_setup_env.subr b/subr/pre_setup_env.subr index 0f2c944..b8e1faa 100644 --- a/subr/pre_setup_env.subr +++ b/subr/pre_setup_env.subr @@ -12,7 +12,7 @@ pre_setup_env() { [ -e ${__} ] && . ${__}; done; for __ in $(export | sed -e 's/^export //' -e 's/=.*$//'); do - if ! match_list "${CLEAR_ENV_VARS_EXCEPT}" " " "${__}"; then + if ! lmatch "${CLEAR_ENV_VARS_EXCEPT}" " " "${__}"; then unset "${__}"; fi; done;