From 432d202a3761559c3004093e84b19b1cbda9bbd8 Mon Sep 17 00:00:00 2001 From: Erwin Janssen Date: Fri, 10 Jun 2016 14:00:11 +0200 Subject: [PATCH] Cleaned Graphviz version date in autogen.sh - Instead of using $? to see whether the last command was successful, the if statement now directly uses the return value. - Moved failed cases to the top. - Using less if-else statements. - Reformulated errors. --- autogen.sh | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/autogen.sh b/autogen.sh index a6c6d538b..c437ee9c3 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,23 +1,16 @@ #! /bin/sh -GRAPHVIZ_GIT_DATE=$( git log -n 1 --format=%ci ) - -if test $? -eq 0; then - GRAPHVIZ_VERSION_DATE=$( date -u +%Y%m%d.%H%M -d "$GRAPHVIZ_GIT_DATE" 2>/dev/null ) - if test $? -ne 0; then +if ! GRAPHVIZ_GIT_DATE=$( git log -n 1 --format=%ci ) ; then + GRAPHVIZ_VERSION_DATE="0" + echo "Warning: build not started in a Git clone, or Git is not installed: setting version date to 0." >&2 +else + if ! GRAPHVIZ_VERSION_DATE=$( date -u +%Y%m%d.%H%M -d "$GRAPHVIZ_GIT_DATE" 2>/dev/null ) ; then # try date with FreeBSD syntax - GRAPHVIZ_VERSION_DATE=$( date -u -j -f "%Y-%m-%d %H:%M:%S %z" "$GRAPHVIZ_GIT_DATE" +%Y%m%d.%H%M ) - if test $? -ne 0; then + if ! GRAPHVIZ_VERSION_DATE=$( date -u -j -f "%Y-%m-%d %H:%M:%S %z" "$GRAPHVIZ_GIT_DATE" +%Y%m%d.%H%M ); then echo "Warning: we do not know how to invoke date correctly." >&2 - else - echo "Version date is based on time of last commit: $GRAPHVIZ_VERSION_DATE" - fi - else - echo "Version date is based on time of last commit: $GRAPHVIZ_VERSION_DATE" + fi fi -else - GRAPHVIZ_VERSION_DATE="0" - echo "Warning: we do not appear to be running in a git clone." >&2 + echo "Graphviz version date is based on time of last commit: $GRAPHVIZ_VERSION_DATE" fi # initialize version for a "stable" build -- 2.40.0