From 2e8bd83dcd29bb6f29382b08994ce2f1f71cea08 Mon Sep 17 00:00:00 2001 From: ville rantanen Date: Fri, 9 Jun 2017 09:52:05 +0300 Subject: [PATCH] file-age now BSD compatible --- files/file-age | 5 ++++- rc | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/files/file-age b/files/file-age index a16dac4..6c42516 100755 --- a/files/file-age +++ b/files/file-age @@ -23,7 +23,10 @@ STATFILE="$1" test -e "$STATFILE" || { echo File "$STATFILE" does not exist >&2; exit 1; } UNITS=${2:-S} -created=$( stat -c %Y "$STATFILE" ) +case $OSTYPE in + darwin*) created=$( stat -f %c -t %s "$STATFILE" ) ;; + linux*) created=$( stat -c %Y "$STATFILE" ) ;; +esac now=$( date +%s ) age=$(( $now - $created )) diff --git a/rc b/rc index aa90186..765b80c 100755 --- a/rc +++ b/rc @@ -1,6 +1,6 @@ # source me to enable tools -TOOLSPATH=$( readlink -f $( dirname "$BASH_SOURCE" ) ) +TOOLSPATH=$( realpath $( dirname "$BASH_SOURCE" ) ) PATH=$PATH:"$TOOLSPATH"/bin [[ "$1" = "-f" ]] && PATH="$TOOLSPATH"/bin:$PATH