From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 5AF3C1F453 for ; Tue, 19 Feb 2019 18:02:30 +0000 (UTC) Received: from localhost ([127.0.0.1]:53018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gw9iv-0000Au-2o for normalperson@yhbt.net; Tue, 19 Feb 2019 13:02:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gw9iq-0000Ac-Fe for bug-gnulib@gnu.org; Tue, 19 Feb 2019 13:02:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gw9ig-00071k-Uy for bug-gnulib@gnu.org; Tue, 19 Feb 2019 13:02:21 -0500 Received: from mo6-p01-ob.smtp.rzone.de ([2a01:238:20a:202:5301::10]:14858) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gw9if-0006yd-TK for bug-gnulib@gnu.org; Tue, 19 Feb 2019 13:02:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1550599331; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=vov6AM89SM52mg0oTSxUfAcHseELbDHvxQ/kzK5TaLg=; b=PMKMMFVhyQA7Tp4flXwBFqiyLGOiRCEMAgpBHj28wH6xkhQ77ilJAcaCiZJy0rAKIA JNIcQ1L7jv7LYSKZpU8TVKABZWDf08ddUu5VIhNiWqq9VYS4by2dhaqZ5ByPz4SSqbye LRlMYAFnzMC2HgB7uBvDE+9aynCiIytyHk+zkrEo87JHa5NbPsdMc/Wz88MYVabWmoQk XVg3ohgvJW0/Nba0TXyJ8k8CBN17I0NuD/Yc4BFWy6kiJtYYvHpWrQw+1s7aZX1oohhA keVAQdFEKHSUO55Mg6HkL/S1v5bkwazbdVM+IZJKMMg6nwjX6ZJWd0NiBFY1jBKFMrbY 8NOw== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGaf3zJZW" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 44.9 DYNA|AUTH) with ESMTPSA id v0a34ev1JI29oWA (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Tue, 19 Feb 2019 19:02:09 +0100 (CET) From: Bruno Haible To: Pavel Raiskup Subject: Re: shell variable references - coding style Date: Tue, 19 Feb 2019 19:02:08 +0100 Message-ID: <2794770.VEEVdL9LWF@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <33012288.smD7kdOuTz@raiskup> References: <6157407.BPRi2t5o0z@omega> <33012288.smD7kdOuTz@raiskup> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5301::10 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Hi Pavel, > > [...] > > This patch fixes both issues, and makes the IFS handling a bit more robust. > > [...] > > > - case $_fpf_arg in > > + case "$_fpf_arg" in > > [...] > > - fpf_dirs=$1 ; shift > > - fpf_cb=$1 ; shift > > + fpf_dirs="$1"; shift > > + fpf_cb="$1"; shift > > [...] > > ... and so on, I don't think it is more robust. At least according to > Autoconf's Shellology [1] it should be actually better to write it the > other way around (without additional quotes). I do think it is more robust, because * The number one mistake in shell scripts (measured by frequency of occurrence) is to reference variables without double quotes when word splitting is in fact undesired. * Simple rules are easier to follow by programmers, resulting in fewer bugs. * The rule "Always double-quote shell variable references, except if you DO want word-splitting." is simpler than "Always double-quote shell variable references, except if you DO want word-splitting OR in the right-hand side of assignments OR as argument of 'case' statements." The text that you quote says two different things: * Backquotes inside double-quotes are hairy. There is a simple rule to avoid them: When you have a backquote expression, always first assign its result to a variable. Then use the variable (with double-quotes, usually). * Bash 4.1 has a bug when you WANT word splitting. These two things don't make my style rule "Always double-quote shell variable references, except if you DO want word-splitting." less robust. > FTR, Gary Vaughan has wrote a syntax checker rules for protecting us from > adding such statements into libtool codebase. Opinions regarding coding style differ. Gary is entitled to his opinion, as much as I am entitled to mine. Bruno > [1] https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/ > Shell-Substitutions.html