commit - 8fedfb3cc9c6c88a5105f3926595d3807da6922d
commit + e33b5f976eb631d64485474683cea67a7cf6f712
blob - ceda4608d69d1238f584e5d362eb9471e406fb2e
blob + 745539b43da693829d69925c94761edf2731751d
--- regress/cmdline/common.sh
+++ regress/cmdline/common.sh
# commands are used.
[ -z "$PLATFORM" -a "$(uname)" = "Linux" ] && PLATFORM="linux"
-[ "$(date -u -r 86400 +%F 2>/dev/null)" = 1970-01-02 ] || date()
-{
- DATECMD="date"
- [ "$PLATFORM" != "linux" ] && {
- command -v "gdate" >/dev/null 2>&1 && {
- DATECMD="gdate"
- } || {
- echo "Couldn't find gdate is GNU coreutils installed?"
- }
- }
-
- local flag r u
- while getopts r:u flag; do
- case $flag in
- r) r=$OPTARG ;;
- u) u=-u ;;
- ?) exit 1 ;;
- esac
+if [ "$(date -u -r 86400 +%F 2>/dev/null)" != 1970-01-02 ]; then
+ DATECMD=
+ for p in date gdate; do
+ if [ "$($p -u -d @86400 +%F 2>/dev/null)" = 1970-01-02 ]; then
+ DATECMD=$p
+ break
+ fi
done
- shift $((OPTIND - 1))
- command "$DATECMD" $u ${r+-d"@$r"} "$@"
-}
+ if [ -z "$DATECMD" ]; then
+ echo "Couldn't find gdate, is GNU coreutils installed?" >&2
+ exit 1
+ fi
+ date()
+ {
+ local flag r u
+ while getopts r:u flag; do
+ case $flag in
+ r) r=$OPTARG ;;
+ u) u=-u ;;
+ ?) exit 1 ;;
+ esac
+ done
+ shift $((OPTIND - 1))
+ command "$DATECMD" $u ${r+-d"@$r"} "$@"
+ }
+fi
+
sed()
{
SEDCMD="sed"