From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 4IjAHGa5s14QfQAA0tVLHw (envelope-from ) for ; Thu, 07 May 2020 07:31:50 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id YOjbIXK5s14jbgAAB5/wlQ (envelope-from ) for ; Thu, 07 May 2020 07:32:02 +0000 Received: from arlo.cworth.org (arlo.cworth.org [50.126.95.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 78BCA940D34 for ; Thu, 7 May 2020 07:31:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 697FB6DE138B; Thu, 7 May 2020 00:31:55 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WMJTcqNXNSkx; Thu, 7 May 2020 00:31:54 -0700 (PDT) Received: from arlo.cworth.org (localhost [IPv6:::1]) by arlo.cworth.org (Postfix) with ESMTP id E4DA06DE0F54; Thu, 7 May 2020 00:31:53 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 08BFF6DE0F54 for ; Thu, 7 May 2020 00:31:52 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3DnQDGQk0rPg for ; Thu, 7 May 2020 00:31:50 -0700 (PDT) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [212.16.98.55]) by arlo.cworth.org (Postfix) with ESMTPS id 1BCC26DE0937 for ; Thu, 7 May 2020 00:31:46 -0700 (PDT) Received: from guru.guru-group.fi (unknown [IPv6:2a02:2380:1:9:5054:ff:feb7:a4bc]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: too) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 28C211B00436; Thu, 7 May 2020 10:31:41 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1588836701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gAn6fzfYwjW7Im/h3h0Ht2Ow9m30W/LrjEaNJ0sQxlI=; b=uPBSVSqJQlCawyIVvZdHFugqks7eaLwJyUbcymeNzsw5/3uC77e2ebWXO9N5nTYNpNLPdS jAwzY7HbduseJlHHfiCJOui8nYU0C4jI0NTYGuxiN8oGEklzM9d1J72Q3gGPgcEx+Q4a02 ZAotyjY8XYVlSaV6uEsuY4s5x0rMLvRjLsRCONd0VJIDILCKxXCIAFGswO17SY8idWeiet hGMEmlRJI28iiBgwGvjcDgo/RBKQw4/mww823I1RKMWUyYYUTIRonFr7FPgDTngaid8QQn H5upBz/01cNj1omOSmref2nblNYOimgU19hz+Spcafb9Ou2Wu45kueAVmesJww== From: Tomi Ollila To: Daniel Kahn Gillmor , Notmuch Mail Subject: Re: [PATCH 1/2] test-lib: mark function variables as local In-Reply-To: <20200506235438.100518-1-dkg@fifthhorseman.net> References: <20200506235438.100518-1-dkg@fifthhorseman.net> User-Agent: Notmuch/0.28.3+84~g41389bb (https://notmuchmail.org) Emacs/25.2.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1588836701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gAn6fzfYwjW7Im/h3h0Ht2Ow9m30W/LrjEaNJ0sQxlI=; b=kjBmuUjJldbFwhTBiGofLRDL/AF4UiWXIQMUZkDgnhE77aExORX+MArniiyB/FN/EsfSua nlOxfQhW7Ef4OLXdhsVQ3E7SQJPWLkyNtoI32OeRBnZzrX4MHiVl3cwrVXRYcVk3Ur5lBP uyD6wce8Rj6183dvtn/bc7vCnZBZvB5pcg2grtDXNwET4kwWLBsUV3JJwuY8n7/CIcqU2i 7ikabEH4eBuNb1+xE+WJdZ/SnAPZ9B6iqYsM1QGYPy04EwwOsPr5DF9QdHSllOzJ8pHKKH EXpyabtaJEAWNVdfd3TOu9GG/LhtavP7z+C5krTKAzimAuweK8f1hx6ktya5EQ== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1588836701; a=rsa-sha256; cv=none; b=M9wCcVoX2NHh62wZ1So5sMsZLDAf8yJQDPSBB32XsGdrtWIwQfzdg2VG+VopEZ7ERZvE8B 2092sPc7bcv1RowLvOp29GxPL2kaOYIZtHMxuL/7BQFDD19BskQkKEtfYsFQsvL5JDEGLo XbVObsr1iSI5Lon52qQx7ifCJPhEIm1aUBg+y5U58EuXDk4/vrqAitWfzfiskt7XyqnuQl Po5RN1spYC5D89/gkSlgya2eIe/gLe6AxyqsNR4EUeezqQEjH+7RN/CandNswJ52zsGTr0 Sya7BKdR9pOhw5TIXMEmXHonptrU7BowOcKy6lAzVfVuYQSbSI4fbot8c0EQkg== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: notmuch-bounces@notmuchmail.org Sender: "notmuch" X-Scanner: scn0 X-Spam-Score: 1.99 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=iki.fi header.s=lahtoruutu header.b=uPBSVSqJ; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 50.126.95.6 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Scan-Result: default: False [1.99 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.45957515585916]; DWL_DNSWL_BLOCKED(0.00)[50.126.95.6:from]; R_SPF_ALLOW(-0.20)[+a:c]; IP_REPUTATION_HAM(0.00)[asn: 27017(-0.18), country: US(-0.00), ip: 50.126.95.6(-0.46)]; R_DKIM_REJECT(1.00)[iki.fi:s=lahtoruutu]; ARC_REJECT(2.00)[signature check failed: fail, {[1] = sig:iki.fi:reject}]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.50)[notmuchmail.org]; RCPT_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[iki.fi:-]; MAILLIST(-0.20)[mailman]; RCVD_IN_DNSWL_FAIL(0.00)[50.126.95.6:server fail]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:27017, ipnet:50.126.64.0/18, country:US]; FROM_NEQ_ENVFROM(0.00)[tomi.ollila@iki.fi,notmuch-bounces@notmuchmail.org]; URIBL_BLOCKED(0.00)[test-lib.sh:url,fifthhorseman.net:email,notmuchmail.org:email]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[notmuch@notmuchmail.org]; DMARC_NA(0.00)[iki.fi]; HAS_LIST_UNSUB(-0.01)[]; RCVD_COUNT_SEVEN(0.00)[8]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: zh+20ZRQGkNq On Wed, May 06 2020, Daniel Kahn Gillmor wrote: > Several functions in test/test-lib.sh used variable names that are > also used outside of those functions (e.g. $output and $expected are > used in many of the test scripts), but they are not expected to > communicate via those variables. > > We mark those variables "local" within test-lib.sh so that they do not > get clobbered when used outside test-lib. Good stuff robustness comment IMO: There is slight difference when writing local foo=`false` and local foo; foo=`false` former does not "fail"; latter does, Although there is (currently!) no difference in our test code (we don't have `set -e` there, IMO the former serves as a bad example for anyone looking the code. (same applies to export foo=`bar`, readonly foo=`bar` and so on, for anyone curious...) IMO better declare all local variables in one line separately, e.g. local output expected and then either output=$1 expected=$2 or output=$1 expected=$2 ( FYI: exection latter in shell differs in a way one could do output=$expected expected=$output ) (IIRC, did not test >;) (add double quotes around $1 and $2 if you desire =D) well, when doing change just add the `local` line, smaller diff :) Tomi > > Signed-off-by: Daniel Kahn Gillmor > --- > test/test-lib.sh | 44 ++++++++++++++++++++++---------------------- > 1 file changed, 22 insertions(+), 22 deletions(-) > > diff --git a/test/test-lib.sh b/test/test-lib.sh > index 5c8eab7c..e8feab3b 100644 > --- a/test/test-lib.sh > +++ b/test/test-lib.sh > @@ -109,7 +109,6 @@ unset ALTERNATE_EDITOR > > add_gnupg_home () > { > - local output > [ -e "${GNUPGHOME}/gpg.conf" ] && return > _gnupg_exit () { gpgconf --kill all 2>/dev/null || true; } > at_exit_function _gnupg_exit > @@ -427,7 +426,7 @@ emacs_fcc_message () > # number of messages. > add_email_corpus () > { > - corpus=${1:-default} > + local corpus=${1:-default} >