From: Tomi Ollila Date: Mon, 10 Feb 2014 21:15:00 +0000 (+0200) Subject: [PATCH v2] support for generating decreasing dates in bash 4.0 and 4.1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2b0edac6df6ba91a60595cdb8c7bd9aa2ca2adc8;p=notmuch-archives.git [PATCH v2] support for generating decreasing dates in bash 4.0 and 4.1 --- diff --git a/c7/338369ffda568d25bd3f88478acc2537f812e7 b/c7/338369ffda568d25bd3f88478acc2537f812e7 new file mode 100644 index 000000000..f59edf08a --- /dev/null +++ b/c7/338369ffda568d25bd3f88478acc2537f812e7 @@ -0,0 +1,76 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 0D2CA431FBD + for ; Mon, 10 Feb 2014 13:15:14 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id h9lMOkHOZn1F for ; + Mon, 10 Feb 2014 13:15:08 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 6B9D9431FAF + for ; Mon, 10 Feb 2014 13:15:08 -0800 (PST) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id 461CB1000FB; Mon, 10 Feb 2014 23:15:02 +0200 (EET) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Subject: [PATCH v2] support for generating decreasing dates in bash 4.0 and + 4.1 +Date: Mon, 10 Feb 2014 23:15:00 +0200 +Message-Id: <1392066900-11207-1-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 1.8.0 +In-Reply-To: <1388593552-25920-1-git-send-email-tomi.ollila@iki.fi> +References: <1388593552-25920-1-git-send-email-tomi.ollila@iki.fi> +Cc: tomi.ollila@iki.fi +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 10 Feb 2014 21:15:14 -0000 + +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. +--- + test/test-lib.sh | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/test/test-lib.sh b/test/test-lib.sh +index 78af170..a1c0f27 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="" +-- +1.8.0 +