From 2cdc8e460a4868bda4f6405248555bc8a2d435f7 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 15 Nov 2016 02:39:57 +0100 Subject: [PATCH] bin/since: refactor --- bin/since | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/since b/bin/since index 48326d3e..3ae319f9 100755 --- a/bin/since +++ b/bin/since @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -e -(( $# > 0 )) || return +(( $# > 0 )) || exit # Displays the time since $1 in a human readable format (e.g. 4h 25m 55s). If given a # file, the modified time is used. If $1 == "--", then this script acts as a converter, @@ -11,18 +11,18 @@ set -e # `date` on OSX does not have the --date parameter date=date -if [[ "$OSTYPE" == darwin* ]]; then +if [[ $OSTYPE == darwin* ]]; then date=gdate -else +elif ! command -v $date >/dev/null; then echo "Unsupported system" exit 1 fi # If given a file, give time since last modification -(( $# == 1 )) && [[ -f "$*" ]] && arg=reference || arg=date +(( $# == 1 )) && [[ -f $@ ]] && arg=reference || arg=date args="$*" -if [[ "$1" == "--" ]]; then +if [[ $1 == -- ]]; then t="$2" else now=$(${date} +%s)