On Tue, 24 Jul 2018 16:40:48 +0100, Ralph Corderoy said:

> How about

>     +fmt='%Y-%m-%d %T %z'
>     +now=${SOURCE_DATE_EPOCH-$(date +%s)}
>     +if date -u -d @42 +"$fmt" >/dev/null 2>&1; then   # Coreutils.
>     +    date=$(date -u -d "@$now" +"$fmt")
>     +elif date -u -r 42 +"$fmt" >/dev/null 2>&1; then   # BSD.
>     +    date=$(date -u -r "$now" +"$fmt")
>     +else   # Posix, ignoring SOURCE_DATE_EPOCH.
>     +    date=$(date -u +"$fmt")
>     +fi

Oh, much better than that date || date || date monstrosity - I was
unable to figure out that the second one was intended for a different
date binary than the first one

Attachment: pgpuKJddMACtk.pgp
Description: PGP signature

-- 
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers

Reply via email to