commit 19a1e617440647775897dcff6faa0846d64d78fa parent 0e55bcced57fd3df8b476ec6a0738816211c6294 Author: Daniel Moch <daniel@danielmoch.com> Date: Sun, 22 Sep 2019 06:39:56 -0400 My: POSIX-compliant age checking for dotfiles A POSIX-compliant find(1) appears not to have a -maxdepth option. This causes problems when trying to determine the time since the last dotfiles update. The problem is solved by using stat(1) instead of find(1). Diffstat:
M | .local/bin/my | | | 8 | ++++++-- |
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/.local/bin/my b/.local/bin/my @@ -347,7 +347,9 @@ case $command in case $predicate in check) cd "$HOME" - find . -maxdepth 1 -name ._.djmoch -mtime +8 -exec echo "Dotfiles more than one week old" \; + aweekago=$(($(date +%s) - 604800)) + lastupdate=$(stat --format=%Y ._.djmoch) + [ $lastupdate -lt $aweekago ] && "Dotfiles more than one week old" ;; update) if [ -d "$HOME/.dotfiles_tgz" ] @@ -418,7 +420,9 @@ case $command in if [ -n "$connected" ] then cd "$HOME" - find . -maxdepth 1 -name ._.djmoch -mtime +8 -exec my dotfiles update \; + aweekago=$(($(date +%s) - 604800)) + lastupdate=$(stat --format=%Y ._.djmoch) + [ $lastupdate -lt $aweekago ] && my dotfiles update fi ;; login)