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 4540E1381F3 for ; Sun, 18 Nov 2012 23:16:46 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6604521C150; Sun, 18 Nov 2012 23:16:07 +0000 (UTC) Received: from mail-ia0-f181.google.com (mail-ia0-f181.google.com [209.85.210.181]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4C58921C14F for ; Sun, 18 Nov 2012 23:13:35 +0000 (UTC) Received: by mail-ia0-f181.google.com with SMTP id h8so3008966iaa.40 for ; Sun, 18 Nov 2012 15:13:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :x-gm-message-state; bh=vJkKHN3dNv0UVMBqyYT9wwHuJVw9cdrihU/T7Ej2BLI=; b=AqMlWxuHsm3vRzHSw9rj/TtiVxkqN1Q8piekz+5SlFuWY+wuBPAdTCgNhTRtRf2XDm m/Mp0iFKfX/kwpjnYBNAEGdLi7I7g9/tTUeNbo2WpmB+roJfF7QA/1Emkrqb99EY5U7v QzH6M+/JiEXtqg4cs1K5IHxepxTTwPj7FVBhyvS6J3iXDLvwFpykEe8WtbY5EcV1Qyol MhnAFC96KHsSDxu0/cU1dosZqsYfgyAOJyg0ABE0hmV86VcaoqDcKc+3QqyU/39UUjZD AVX74TqaLdEe/Ded8HOWXw6tL2VMXfgNt+qMMrZCa5lrVLrjYf6zg6Zku3zzLq8CzgZW i+Hg== 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 Received: by 10.50.208.99 with SMTP id md3mr4995860igc.67.1353280414595; Sun, 18 Nov 2012 15:13:34 -0800 (PST) Sender: antarus@scriptkitty.com Received: by 10.64.23.114 with HTTP; Sun, 18 Nov 2012 15:13:34 -0800 (PST) In-Reply-To: References: <1353265590.23950.13.camel@kanae> Date: Sun, 18 Nov 2012 15:13:34 -0800 X-Google-Sender-Auth: A_bBCDb6iu3qSUwJzyqXzjM5cv0 Message-ID: Subject: Re: [gentoo-dev] Re: gstreamer eclass review From: Alec Warner To: gentoo-dev@lists.gentoo.org Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQkO7FJ0ONdlXiutFWV57XfkcaUc1x0lXmbFOqG3bsHGESVBipWPaM/Y9FSt/7anEG2cMiPF X-Archives-Salt: 2f25bb0e-d7b7-40cb-9af7-2d1fa68ef5dd X-Archives-Hash: 5af2189738920d8593207036dc221a38 On Sun, Nov 18, 2012 at 12:45 PM, Duncan <1i5t5.duncan@cox.net> wrote: > Gilles Dartiguelongue posted on Sun, 18 Nov 2012 20:06:30 +0100 as > excerpted: > > It's admittedly a style thing thus pretty much up to the author, purely > bikeshedding in the original sense of the essay's trivial color choice, > but... > >> # Even though xz-utils are in @system, they must still be added to DEPEND; see >> # http://archives.gentoo.org/gentoo-dev/msg_a0d4833eb314d1be5d5802a3b710e0a4.xml >> if [[ ${GST_TARBALL_SUFFIX} == "xz" ]]; then >> DEPEND="${DEPEND} app-arch/xz-utils" >> fi > > Single-clause conditional tests (without an else clause) such as the above > can be trivially rewritten like so: > > [[ ${GST_TARBALL_SUFFIX} == "xz" ]] && \ > DEPEND="${DEPEND} app-arch/xz-utils" > > Two lines (or one if short enough) instead of three and more concise (fi > line omitted entirely, "if" omitted, "; then" replaced with &&). http://www.quickmeme.com/meme/3ru1zx/ > > It's possible to do similar with if/then/else -> &&/||, but that may > require {} for clarity if not bash parsing, and IMO is not nearly as > clear as the more straightforward no-else-clause case. So if there's > an else clause, I prefer if/then/else; if not, I prefer the && or || logic. > >> if [[ ${PN} != ${GST_ORG_MODULE} ]]; then >> # Do not run test phase for invididual plugin ebuilds. >> RESTRICT="test" >> fi > > Another example, this one definitely a one-liner (plus comment, > "invididual" typo left intact)... > > # Do not run test phase for invididual plugin ebuilds. > [[ ${PN} != ${GST_ORG_MODULE} ]] && RESTRICT="test" > > Or, avoiding that ! in the test and changing the && to ||... > > [[ ${PN} == ${GST_ORG_MODULE} ]] || RESTRICT="test" > > Also, while we're here, "test" is a string-literal with no possibility of > spaces or anything else that could otherwise confuse bash, so needs no > quotes. And I'm not sure if the != pattern matching trigger was > deliberate or not (see bash's "help [[" output). Thus... > > [[ ${PN} = ${GST_ORG_MODULE} ]] || RESTRICT=test > > ... or... > > [[ ${PN} == ${GST_ORG_MODULE} ]] || RESTRICT=test > > ... with the single vs. double equals making the string match (single) vs > pattern match (double) explicit. If the test-internal-not form is > retained, the string match form would be... > > [[ ${PN} ! = ${GST_ORG_MODULE} ]] && RESTRICT=test > > ... while the pattern match form would retain the != that was used > (the distinction being the separating space, != is a pattern match > as is ==, ! = is a string match as is a single = ). > > >> # added to remove circular deps # 6/2/2006 - zaheerm > if [[ ${PN} != ${GST_ORG_MODULE} ]]; then >> RDEPEND="${RDEPEND} media-libs/${GST_ORG_MODULE}:${SLOT}" >> fi > > Ditto... Further examples skipped. > >> # @FUNCTION: gst-plugins10_src_install gst-plugins10_src_install() { >> gst-plugins10_find_plugin_dir >> >> if has "${EAPI:-0}" 0 1 2 3 ; then >> emake install DESTDIR="${D}" || die >> [[ -e README ]] && dodoc README >> else >> default >> fi >> >> [[ ${GST_LA_PUNT} = "yes" ]] && prune_libtool_files --modules >> } > > Here (last line before the function-closing "}", as I said above, I prefer > if/then/else where there's an else clause, so wouldn't change the upper > conditional) we see a counter-example, doing it just as I suggested. > The if/then version (keeping function indent) would look like this. > > if [[ ${GST_LA_PUNT} = "yes" ]]; then > prune_libtool_files --modules > fi > > Of course regardless of that, the quotes around "yes" may be omitted as > it's a string literal. (And here, the explicit single-equals string- > literal match is used, as opposed to the double-equals pattern match. Of > course either one would work here as it's a trivial pattern, just noting > it for consistency.) > > [[ ${GST_LA_PUNT} = yes ]] && prune_libtool_files --modules > > > But as I said up top, that's (mostly, the pattern matching vs string > matching will occasionally bite if you're not on the lookout for it) > trivial style stuff. You may well prefer the way it is now. But in that > case, why the counter-example, omitting if/then? (You may of course > fairly point out that consistency is a trivial style thing too. =:^) > > -- > Duncan - List replies preferred. No HTML msgs. > "Every nonfree program has a lord, a master -- > and if you use the program, he is your master." Richard Stallman > >