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 3FA12431FCF for ; Mon, 9 Dec 2013 00:21:09 -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 5D+EmkDFunDc for ; Mon, 9 Dec 2013 00:21:01 -0800 (PST) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id 7A941431FC0 for ; Mon, 9 Dec 2013 00:21:01 -0800 (PST) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id 0ECBD10005D; Mon, 9 Dec 2013 10:20:52 +0200 (EET) From: Tomi Ollila To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 4/4] test: give unique timestamps to messages In-Reply-To: <87lhzult3h.fsf@maritornes.cs.unb.ca> References: <1386517946-22054-1-git-send-email-david@tethera.net> <1386517946-22054-5-git-send-email-david@tethera.net> <87lhzult3h.fsf@maritornes.cs.unb.ca> User-Agent: Notmuch/0.17~rc1+17~ga2e1a2f (http://notmuchmail.org) Emacs/24.3.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain 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, 09 Dec 2013 08:21:09 -0000 On Mon, Dec 09 2013, David Bremner wrote: > Tomi Ollila writes: > >>> if [ -z "${template[date]}" ]; then >>> - template[date]="Fri, 05 Jan 2001 15:43:57 +0000" >>> + template[date]=$(date -Ru -d@$((978709437 - gen_msg_cnt))) >> >> I am afraid this is not portable (although not sure). This could work: >> >> _s=$((3599 - gen_msg_cnt)) >> template[date]="Fri, 05 Jan 2001 15:$((_s / 60)):$((_s % 60)) +0000" >> > > How about this instead? > > diff --git a/test/test-lib.sh b/test/test-lib.sh > index 792e477..22a4d7f 100644 > --- a/test/test-lib.sh > +++ b/test/test-lib.sh > @@ -356,7 +356,8 @@ generate_message () > fi > > if [ -z "${template[date]}" ]; then > - template[date]=$(date -Ru -d@$((978709437 - gen_msg_cnt))) > + template[date]=$(TZ=UTC printf "%(%a, %d %b %Y %T %z)T\n" \ > + $((978709437 - gen_msg_cnt))) > fi $ printf "%(%a, %d %b %Y %T %z)T\n" 978709437 printf: %(: invalid directive zsh: exit 1 $ bash -c 'printf "%(%a, %d %b %Y %T %z)T\n" 978709437' Fri, 05 Jan 2001 17:43:57 +0200 Using bash builtin is fine by me! :D BTW: this works too: bash -c 'TZ=UTC printf -v foo[bar] "%(%a, %d %b %Y %T %z)T\n" 978709437; echo ${foo[bar]}' Tomi