From f29d9440b856c884b3a3046ac1c696433c06f5ae Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Thu, 15 Oct 2015 12:34:08 -0700 Subject: Provides a fix for Isssue #69. --- radar-base.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/radar-base.sh b/radar-base.sh index 258e5b1..429fa8f 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -1,6 +1,7 @@ NO_REMOTE_STATUS='--no-remote-status' dot_git="" +stat_type="" cwd="" remote="" rcfile_path="$HOME" @@ -119,6 +120,15 @@ dot_git() { fi } +stat_type() { + if [[ "$OSTYPE" == "darwin"* ]]; then + stat_type="gstat" + else + stat_type="stat" + fi + printf '%s' $stat_type +} + is_repo() { if [[ -n "$(dot_git)" ]]; then return 0 @@ -143,7 +153,7 @@ record_timestamp() { timestamp() { if is_repo; then - printf '%s' "$(stat -f%m "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")" + printf '%s' "$("$(stat_type)" -c%Z "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")" fi } -- cgit v1.2.3 From 3aec9621ca391d8ea61df4daddb407a7acf1ecf6 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Thu, 15 Oct 2015 12:51:18 -0700 Subject: Removed unnecessary quotes. --- radar-base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radar-base.sh b/radar-base.sh index 429fa8f..02b1bb9 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -153,7 +153,7 @@ record_timestamp() { timestamp() { if is_repo; then - printf '%s' "$("$(stat_type)" -c%Z "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")" + printf '%s' "$($(stat_type) -c%Z "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")" fi } -- cgit v1.2.3 From 532d76036d5d5cd9161d90a735ed0edd1f9c869d Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Fri, 16 Oct 2015 13:08:05 +0100 Subject: %Z returns the modified date, %Y returns the changed date The OSX version of stat uses %m to return the 'modified' date since epoch. The GNU version of stat doesn't have the %m format code. %Z which was being used in @hallzy's fix returns the 'changed' date since epoch, which only changes when you modify the metadata on a file. This meant that when we `touch $dot_git/.lastupdatetime` the 'changed' date doesn't change. I've switched to the %Y flag which returns the 'modified' time. This is the time that is changed when `touch` modifies the file. --- radar-base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radar-base.sh b/radar-base.sh index 02b1bb9..7c27165 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -153,7 +153,7 @@ record_timestamp() { timestamp() { if is_repo; then - printf '%s' "$($(stat_type) -c%Z "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")" + printf '%s' "$($(stat_type) -c%Y "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")" fi } -- cgit v1.2.3