aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPaul Spooren <mail@aparcar.org>2020-08-15 10:57:00 -1000
committerDaniel Golle <daniel@makrotopia.org>2020-08-31 11:18:06 +0100
commitae87e53e33a7e914ec340bebb45cb177724f5952 (patch)
tree571730b26f8c3c750c8707934672d2aa02a0f3cb /scripts
parent7d26f294cd0b2bd4ea3475e55e6c68cf0ede46ac (diff)
downloadupstream-ae87e53e33a7e914ec340bebb45cb177724f5952.tar.gz
upstream-ae87e53e33a7e914ec340bebb45cb177724f5952.tar.bz2
upstream-ae87e53e33a7e914ec340bebb45cb177724f5952.zip
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 <mail@aparcar.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/get_source_date_epoch.sh7
1 files changed, 5 insertions, 2 deletions
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" ]
}