Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4918708ybi; Mon, 3 Jun 2019 20:47:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzG17Ncu0HCIPyHtp6lzIK92bRMHSRI4tsqms+Tlydaa4Q/Doag01KmgL1VD8YB65dI0ZJY X-Received: by 2002:a65:62cc:: with SMTP id m12mr32697476pgv.237.1559620055493; Mon, 03 Jun 2019 20:47:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559620055; cv=none; d=google.com; s=arc-20160816; b=hkCIlV7Jp2Qx8Rw1EPiijDH5u08JxRGIsizuZwq9u7an+Ekdb684trkpEGyHICmhrw 3+MdehTMp7sk9JEoaZeEZSLKZwMPilTTkLuzqYQoVNWC4e4fa+3TGqZc2RAraQ/wD0kS YVG6bCOlOKajT3p1OUsPp2BkteI/DkhN8zrTAW3JWVSxeYj0eGOMszwniajyl4VGzgah 9WGZYpiZQxQ5PNcMH4zYjMGr8vcln4Tx71IHoD243hs45oNmRO7FrHjjRtNasUZx1rBZ o9I7EuddKmOio4Rw6bu578bAhbje802Ez8Hsc9nvUpAcBJzEsVYacVjgHDDFX/o0f2TK JkWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=R4DTbEc9ajd/+gLs4R0E3A2qZCd8mpp6nT3mLt/MWL4=; b=dW0lUmSw+sP9YiYbHPO8/O6XbcRJECWzWIyXzFuyJGm3DA7q9M3b/RIy8geTIQIQgq Yt+gomoqrLx6orvtmlaoJDC9DqbIQNNKfmBLQ+4Ki+989bakYSwZElqJVSCqVp4mPNne JAEt4l5DWvnTxNwmFvKxYkskp6750gmV1H7xq5IeF/EO/403NPs0Vxth3gygqJk84/T6 lS2fHA3GXsy0qyot3guSll2oMwI78lXYg1tjit+g/NrPMG1TzlsqpoEW7wia268xvClq DrCSOHsgy9E8xM+KNzIxd6IT0at+dd8Pe/sSbF4qxsevnUV6UvlCES+bNflcB3ECrh8y I5Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=sSBx0AvD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4si19378911plm.209.2019.06.03.20.47.05; Mon, 03 Jun 2019 20:47:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=sSBx0AvD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726427AbfFDDpQ (ORCPT + 99 others); Mon, 3 Jun 2019 23:45:16 -0400 Received: from conssluserg-01.nifty.com ([210.131.2.80]:61764 "EHLO conssluserg-01.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726136AbfFDDpQ (ORCPT ); Mon, 3 Jun 2019 23:45:16 -0400 Received: from mail-ua1-f41.google.com (mail-ua1-f41.google.com [209.85.222.41]) (authenticated) by conssluserg-01.nifty.com with ESMTP id x543j1JO005406; Tue, 4 Jun 2019 12:45:02 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com x543j1JO005406 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1559619902; bh=R4DTbEc9ajd/+gLs4R0E3A2qZCd8mpp6nT3mLt/MWL4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=sSBx0AvDkKyPdfmLobt1FwXeI8jVeiK59RkpnvzCgW1NxC772shGT0Sxc6PAO3Ks8 PDpJD75pBEKoT6FtjYqkPmeN7nHHdv/MoXFZ+KkARrl7JX7aMkTjv66C+gvwBFrf1k B8WFehagQofx/8TM/rEZq5ZQsCBBOmcPxP90UVmxzfiuyDbP2A1GnZ1/QcxY8pzP35 peOxnzSOfUkm2Oyv22A6p/BEmKU4ophBttj/ymoil1dI3SwP/qqDWA9vS74RKRv/jT /r3Ba2dTESj1A1/ZKgvGfqHlnmrjZUEmgp2ARlAXb79sSmfu3ocxF13RuVLBIBPzcu YPiPeujYRKBIg== X-Nifty-SrcIP: [209.85.222.41] Received: by mail-ua1-f41.google.com with SMTP id a95so7261755uaa.13; Mon, 03 Jun 2019 20:45:01 -0700 (PDT) X-Gm-Message-State: APjAAAUDLD4J7SDn84VESpww0jFOtVdyaxzxZkz3jlvcuRBawx9H1ufg Wa6JAZalYrKRQzhmYB2rT60+g0H5PRFCXvJxdsU= X-Received: by 2002:a9f:24a3:: with SMTP id 32mr13276265uar.109.1559619900888; Mon, 03 Jun 2019 20:45:00 -0700 (PDT) MIME-Version: 1.0 References: <20190603104902.23799-1-yamada.masahiro@socionext.com> <3dcacca3f71c46cc98fa64b13a405b59@AcuMS.aculab.com> <1ca8a995328f449fa58f732ebe70e378@AcuMS.aculab.com> In-Reply-To: <1ca8a995328f449fa58f732ebe70e378@AcuMS.aculab.com> From: Masahiro Yamada Date: Tue, 4 Jun 2019 12:44:25 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kbuild: use more portable 'command -v' for cc-cross-prefix To: David Laight Cc: "linux-kbuild@vger.kernel.org" , Vineet Gupta , Alexey Brodkin , "linux-snps-arc@lists.infradead.org" , linux-stable , Michal Marek , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 3, 2019 at 9:43 PM David Laight wrote: > > From: Masahiro Yamada > > Sent: 03 June 2019 12:45 > > On Mon, Jun 3, 2019 at 8:16 PM David Laight wrote: > > > > > > From: Masahiro Yamada > > > > Sent: 03 June 2019 11:49 > > > > > > > > To print the pathname that will be used by shell in the current > > > > environment, 'command -v' is a standardized way. [1] > > > > > > > > 'which' is also often used in scripting, but it is not portable. > > > > > > All uses of 'which' should be expunged. > > > It is a bourne shell script that is trying to emulate a csh builtin. > > > It is doomed to fail in corner cases. > > > ISTR it has serious problems with shell functions and aliases. > > > > OK, I do not have time to check it treewide. > > I expect somebody will contribute to it. > > > > > > > > BTW, I see yet another way to get the command path. > > > > 'type -path' is bash-specific. > > 'type' itself should be supported by all shells, but the output > format (esp for errors) probably varies. > > > Maybe, we should do this too: > > > > diff --git a/scripts/mkuboot.sh b/scripts/mkuboot.sh > > index 4b1fe09e9042..77829ee4268e 100755 > > --- a/scripts/mkuboot.sh > > +++ b/scripts/mkuboot.sh > > @@ -1,14 +1,14 @@ > > -#!/bin/bash > > +#!/bin/sh > > /bin/sh might be 'dash' - which is just plain broken in so many ways. > Try (IIRC) ${foo%${foo#bar}} > It might even be the original SYSV /bin/sh which doesn't support $((expr)) > or ${foo#bar} - but that may break too much, but $SHELL might fix it. We cannot use any tool if you start to argue like "Hey, I know ancient implementation that did not work as expected". Nobody can cover all corner-cases. That's why we have standard. I think the reliable source is the Open Group Specification. The behavior of /bin/sh is defined here: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_01 ${parameter%[word]} and ${parameter#[word]} are defined, so we can use them in /bin/sh scripts. > dash probably has the rather obscure bug in stripping '\n' from $(...) > output that I found and fixed in NetBSD's ash may years ago. > Try: foo="$(jot -b "" 130)" > All 130 '\n' should be deleted. > Mostly it fails to delete all the '\n', but it can remove extra ones! > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) -- Best Regards Masahiro Yamada