From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 5CE8913849F for ; Tue, 15 Jan 2013 05:03:32 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7C1A121C075; Tue, 15 Jan 2013 05:03:28 +0000 (UTC) Received: from mail-ie0-f170.google.com (mail-ie0-f170.google.com [209.85.223.170]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 79ADA21C00F for ; Tue, 15 Jan 2013 05:03:27 +0000 (UTC) Received: by mail-ie0-f170.google.com with SMTP id k10so6583119iea.1 for ; Mon, 14 Jan 2013 21:03:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=MGf1i8mDxvsTeVFnl2fUPmG+PXGq5UT2MN5eN61INzQ=; b=hQPW//t3ItNLcYgwuSMWNc0ZaqveL7cHclHDaBeoFoOkVrlPSulAuN5VF8tUYSvy/6 ar/1MH1f5Hx9DSU+WSqAYMF1enSOJgIS1sLzxrRnhvq11hW+k6CroLSJkUSKVEiW5eHs UJbutsipQFm4faZXzPZZXoZgn0NuLF1juzWMgxuR2ZYVTyPvGiU4Qp9V+TbhkT9Z0vvq qylRkVffRErRSe2wcJPnu7/5tBV5hOz4ozPQRfxt/NEcOyRFa/IsEFrr+tAtwm/WONHw i+oJxJi/+kwBSmsMHrqlpfezdaOSRPY2ckSwe7r5wHhnUWqWafLsyYkk5z9bCpb0Q3w3 /zOQ== X-Received: by 10.50.91.168 with SMTP id cf8mr761119igb.20.1358226206761; Mon, 14 Jan 2013 21:03:26 -0800 (PST) Received: from ormaajbox (63-231-148-118.mpls.qwest.net. [63.231.148.118]) by mx.google.com with ESMTPS id l8sm1272356igo.13.2013.01.14.21.03.24 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Jan 2013 21:03:25 -0800 (PST) From: Dan Douglas To: gentoo-dev@lists.gentoo.org Subject: Re: [gentoo-dev] Re: [PATCH eutils] Introduce run_in_build_dir() used in a few ebuilds. Date: Mon, 14 Jan 2013 23:03:12 -0600 Message-ID: <5390587.p9q4UcykIo@smorgbox> User-Agent: KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; ) In-Reply-To: References: <1358083783-27015-1-git-send-email-mgorny@gentoo.org> <201301141709.51771.vapier@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1398153.kNGkTds6HE"; micalg="pgp-sha1"; protocol="application/pgp-signature" Content-Transfer-Encoding: 7Bit X-Archives-Salt: b8c000eb-26b5-4286-bd8c-cfb5d1919bf1 X-Archives-Hash: 91ab78c7cc3724d3c4f34785a677834f --nextPart1398153.kNGkTds6HE Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" On Tuesday, January 15, 2013 03:20:20 AM Duncan wrote: > Mike Frysinger posted on Mon, 14 Jan 2013 17:09:51 -0500 as excerpted: > > >>> + [[ ${BUILD_DIR} ]] || die "${FUNCNAME}: BUILD_DIR not set." > >> > >> really should use -n there > > > >> Doesn't matter. > > > > the point wasn't "will it work". it's more "how easy is it to glance at > > code and know what it is doing". > > Indeed. But arguably standalone [[ ${var} ]] tests ARE easier to "know > what it doing." While I agree, I wouldn't lose sleep over it. Both are perfectly acceptable and nearly equal in clarity. [[ $x ]] is probably most common. > Consider: > ... > 4) You are arguing the "at a glance" position, but didn't even MENTION > the needlessly negated logic of [[ -n $string ]] || ... , which could be > rewritten to avoid the || negation as [[ -z $string ]] && ... -z is the negation. -n is the default. [[ $x ]] is rewritten internally as [[ -n $x ]]. [[ ! $x ]] == [[ ! -n $x ]] == [[ -z $x ]]. It's perfectly logical that this expression evaluates true when given a non-empty value. As ''expr || die'' is the most expected form for error-checking, negating this with ''-z'' or otherwise makes little sense. "Empty == False" is not an uncommon concept. e.g. python -c 'print(bool(""))' > 5) [[ ]] is already a bashism while the standalone string test is common > shell. Surely you're not arguing that people familiar enough with the > [[ ]] || construct to parse it at a glance can't equally capably parse > the a standalone string test, given its use in non-bash shell context as > well. I wish people would stop referring to features that predate both Bash and POSIX as "Bashisms". ''[['' is superior to and easier to understand than ''[''. Everyone should be familiar with both. As only Bash is relevant here, ''test'' and ''['' are mostly irrelevant. With few exceptions, ''[['' should be preferred when available (and in this case, guaranteed available). > Obviously the example in #6 is taking it a bit far, but my point is, an > explicit (if one-of-many) -z/-n test vs. the standalone (single-case) > $string test really is personal preference. The performance difference is considerable. -- Dan Douglas --nextPart1398153.kNGkTds6HE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iEYEABECAAYFAlD04xYACgkQMmyDamdg+MyHCgCglRQRW2RjE2Do0Ibkch491a9J mogAn3jEvP9cCVHLuJQ6Rw7SJ+g6mQ1h =FJri -----END PGP SIGNATURE----- --nextPart1398153.kNGkTds6HE--