From b03d3cc271d6c91e2d64adeb6b7ed742fa26066e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Sat, 4 Apr 2020 19:45:50 +0100 Subject: subr/rtl_complex.subr:rtl_is_newer(): reimplemented w/ stat(1). subr/build_init.subr:buildp_init_prereqs(): adds stat(1). --- subr/build_init.subr | 2 +- subr/rtl_complex.subr | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'subr') diff --git a/subr/build_init.subr b/subr/build_init.subr index 49f0dca8..668c0861 100644 --- a/subr/build_init.subr +++ b/subr/build_init.subr @@ -229,7 +229,7 @@ buildp_init_prereqs() { g++ gcc git grep gunzip gzip hostname id install kill \ ln lzip make mkdir mkfifo mktemp mv paste patch perl \ pgrep pkill printf readlink rm sed sha256sum sort \ - tail tar test touch tr uniq wget xz zip; then + stat tail tar test touch tr uniq wget xz zip; then printf "%s\n" "${_status}" >&2; exit 1; elif ! (FNAME="$(mktemp)" && { trap "rm -f \"\${FNAME}\"" EXIT; \ sed -i'' -e '' "${FNAME}" >/dev/null 2>&1; }); then diff --git a/subr/rtl_complex.subr b/subr/rtl_complex.subr index 2c23cfe8..4a055515 100644 --- a/subr/rtl_complex.subr +++ b/subr/rtl_complex.subr @@ -164,11 +164,16 @@ rtl_head() { }; rtl_is_newer() { - local _new_fname="${1}" _old_fname="${2}"; - if [ -n "$(find -name "${_new_fname}" -newer "${_old_fname}" 2>/dev/null)" ]; then + local _new_fname="${1}" _old_fname="${2}" _new_ts="" _old_ts=""; + if ! [ -e "${_old_fname}" ]; then return 0; - else - return 1; + else _new_ts="$(stat -c %Y "${_new_fname}" 2>&1)"; + _old_ts="$(stat -c %Y "${_old_fname}" 2>&1)"; + if [ "${_new_ts:-0}" -gt "${_old_ts:-0}" ]; then + return 0; + else + return 1; + fi; fi; }; -- cgit v1.2.3