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>
#!/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
}
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" ]
}