From: Paul Spooren Date: Sat, 15 Aug 2020 20:57:00 +0000 (-1000) Subject: build: Fix Shellcheck for get_source_date_epoch.sh X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=ae87e53e33a7e914ec340bebb45cb177724f5952;p=openwrt%2Fstaging%2Fadrian.git build: Fix Shellcheck for get_source_date_epoch.sh If a `cd` to `TOPDIR` fails the script should quit. Also unify `try_mtime` function by storing it in a variable. Signed-off-by: Paul Spooren --- diff --git a/scripts/get_source_date_epoch.sh b/scripts/get_source_date_epoch.sh index 84ba445454..8a41eebae7 100755 --- a/scripts/get_source_date_epoch.sh +++ b/scripts/get_source_date_epoch.sh @@ -1,7 +1,10 @@ #!/usr/bin/env bash export LANG=C export LC_ALL=C -[ -n "$TOPDIR" ] && cd $TOPDIR + +if [ -n "$TOPDIR" ]; then + cd "$TOPDIR" || exit 1 +fi try_version() { [ -f version.date ] || return 1 @@ -22,7 +25,7 @@ try_hg() { } try_mtime() { - perl -e 'print((stat $ARGV[0])[9])' "$0" + SOURCE_DATE_EPOCH=$(perl -e 'print((stat $ARGV[0])[9])' "$0") [ -n "$SOURCE_DATE_EPOCH" ] }