From d7b9cd526df69c1aed0cd28bb94a4c2840910861 Mon Sep 17 00:00:00 2001 From: Jorge Bucaran Date: Sun, 7 Oct 2018 02:18:46 +0900 Subject: [PATCH] fix: use perl for epoch only on FreeBSD & Darwin; fix #458 --- fisher.fish | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fisher.fish b/fisher.fish index 0c5ac8d..543d310 100644 --- a/fisher.fish +++ b/fisher.fish @@ -2,14 +2,15 @@ set -g fisher_version 3.0.3 type source >/dev/null; or function source; . $argv; end -if command which perl >/dev/null - function _fisher_now -a elapsed - command perl -MTime::HiRes -e 'printf("%.0f\n", (Time::HiRes::time() * 1000) - $ARGV[0])' $elapsed - end -else - function _fisher_now -a elapsed - command date "+%s%3N" | command awk "{ sub(/3N\$/,\"000\"); print \$0 - 0$elapsed }" - end +switch (command uname) + case Darwin FreeBSD + function _fisher_now -a elapsed + command perl -MTime::HiRes -e 'printf("%.0f\n", (Time::HiRes::time() * 1000) - $ARGV[0])' $elapsed + end + case \* + function _fisher_now -a elapsed + command date "+%s%3N" | command awk "{ sub(/3N\$/,\"500\"); print \$0 - 0$elapsed }" + end end function fisher -a cmd -d "fish package manager"