aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Tomi Ollila <tomi.ollila@iki.fi>2014-02-10 23:15:00 +0200
committerGravatar David Bremner <david@tethera.net>2014-03-09 10:09:51 -0300
commite79d2fc993dcd6fb328c31b2a0466cf7413a8276 (patch)
tree0ddb3f4f7b8eb3cb8c26141ef21f3cd6c1f1c84b /test
parentd8ba7bee7d3dd3b7b47c7bfd96434effef7227f0 (diff)
support for generating decreasing dates in bash 4.0 and 4.1
The printf builtin "%(fmt)T" specifier (which allows time values to use strftime-like formatting) is introduced in bash 4.2. Trying to execute this in pre-4.2 bash will fail -- and if this happens execute the fallback piece of perl code to do the same thing.
Diffstat (limited to 'test')
-rw-r--r--test/test-lib.sh8
1 files changed, 6 insertions, 2 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 9222689d..66edb7c9 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -374,8 +374,12 @@ generate_message ()
# we use decreasing timestamps here for historical reasons;
# the existing test suite when we converted to unique timestamps just
# happened to have signicantly fewer failures with that choice.
- template[date]=$(TZ=UTC printf "%(%a, %d %b %Y %T %z)T\n" \
- $((978709437 - gen_msg_cnt)))
+ local date_secs=$((978709437 - gen_msg_cnt))
+ # printf %(..)T is bash 4.2+ feature. use perl fallback if needed...
+ TZ=UTC printf -v template[date] "%(%a, %d %b %Y %T %z)T" $date_secs 2>/dev/null ||
+ template[date]=`perl -le 'use POSIX "strftime";
+ @time = gmtime '"$date_secs"';
+ print strftime "%a, %d %b %Y %T +0000", @time'`
fi
additional_headers=""