Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8414244ybn; Tue, 1 Oct 2019 07:48:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxhxkE4/Fv7iRYZqLQcc720myvVeb8xEKOvuWU/TLvyl0C1BpaK/Rvvgw36wQrtMxO1PQa X-Received: by 2002:a17:906:134b:: with SMTP id x11mr24152694ejb.272.1569941318108; Tue, 01 Oct 2019 07:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569941318; cv=none; d=google.com; s=arc-20160816; b=yazABySMqLtZL9MT8tyDbSp7lPcgpYRrj8/qEQ25kc4ZGr8i1K/qKWEYEiyD+pVhYW HRSd03NyxI/43mVYAmf0X1jyZ9/191sbTYSKAeUFFoPPEf/gARcz+jDVNdSEqRaiWeym KdW1hwFWDg9TVMEb+t+0AUdSxRDnoBP8mP22CAt4g4Hmx0HyfVgd55Lzacdsv5Deeo/h XWHdV2FIrupVi9jeYXlZUdmd0/rxoopPbLvJD0a3T//EXObTUXkfPaivq7YBCrVF8bBU moEzfAP9WHOS/5p7uWJ9EEPD5yomiYS5rlcjRAAZdHwVrwM5R1aK7am3KR2Bv2Jo/tmj RAmw== 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=7Bvi5CB0Y/ucWirAJcxGpfKhycv9MrI86dSeJ1hyRV8=; b=OElFxgM0bWwjRSIDV6trNnXRLZKS/Geifa+Jn12iVPA0yIFEyfGZTkoaBgMxdiB9lP GW0qftmD8NCiixfh84Cqk1EvR5yVURmGI1DD6dqilsD+up34Z6pHFosN8egaheg0STYI YjiK1JTbxL5XlbNEvL2237mBVFXz8bgoN5KnnGASfc53LE7/kUzJN6HzjKkegsOpY7a9 AmPk6O7n/0xuiPKil8jkui6MGXJ8aZKR6s6tZ0mxPbQbIvAYmaVCaIh8tqctJdF3cz8h 0mvTLEpjEqYz17QAM5Gqp3+gfw88xYz7fafuW7DgjxLbB0/6YX4/4bPsyZqG/p0/QLmW Guxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ulyr0khH; 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 y9si9016730edv.405.2019.10.01.07.48.12; Tue, 01 Oct 2019 07:48:38 -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=ulyr0khH; 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 S2389234AbfJAOpw (ORCPT + 99 others); Tue, 1 Oct 2019 10:45:52 -0400 Received: from conssluserg-05.nifty.com ([210.131.2.90]:18710 "EHLO conssluserg-05.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388953AbfJAOpw (ORCPT ); Tue, 1 Oct 2019 10:45:52 -0400 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (authenticated) by conssluserg-05.nifty.com with ESMTP id x91Ejjxr024273 for ; Tue, 1 Oct 2019 23:45:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com x91Ejjxr024273 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1569941145; bh=7Bvi5CB0Y/ucWirAJcxGpfKhycv9MrI86dSeJ1hyRV8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ulyr0khHHe36KPGJCJrnxu8e9T8xzFpB1O00oAj36lfn4CUt3QcjhRrB9O/quF70h GU0U2qYbhlR9QGlWcmSbd3SyDCJYHJuLbHmNQCSfTqU5Tr4YqL+ZMpurdarZI46wk9 tt3AeCrLDrLqQB+A6JEYHFOCn9sbXfuthFGALkFXKprHA2hTTzrTjKst8wCODA/nMl B64fmZtzxuOm+pPgQon20stGHrbGKj89oMRaVeeVJRnxG3uO6lML3eZz/Xqj9uboHQ OoMTUyMW3LsOC3M8CBdhlnx7C4b+GHYf6gtnu1XA61YAP7VHFFupW+OLofSCD6XkSS 4HZ+2v6rfisCg== X-Nifty-SrcIP: [209.85.222.174] Received: by mail-qk1-f174.google.com with SMTP id y189so11485832qkc.3 for ; Tue, 01 Oct 2019 07:45:45 -0700 (PDT) X-Gm-Message-State: APjAAAWzHEBDSZh69LKo/Kue13FUZlnqUcy4mAiDt2ryutux77jZSrzM 2CmDDurMezuCMh/SghDd75pkLmiJXPphiVL2JKo= X-Received: by 2002:a05:620a:6b6:: with SMTP id i22mr6449417qkh.477.1569941144328; Tue, 01 Oct 2019 07:45:44 -0700 (PDT) MIME-Version: 1.0 References: <20191001121724.23886-1-yamada.masahiro@socionext.com> In-Reply-To: From: Masahiro Yamada Date: Tue, 1 Oct 2019 23:45:07 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] scripts/setlocalversion: clear local varaible to make it work for sh To: Geert Uytterhoeven Cc: Linux Kernel Mailing List 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 Hi Geert, On Tue, Oct 1, 2019 at 10:20 PM Geert Uytterhoeven wrote: > > Hi Yamada-san, > > s/varaible/variable/ in subject. > > On Tue, Oct 1, 2019 at 2:17 PM Masahiro Yamada > wrote: > > Geert Uytterhoeven reports a strange side-effect of commit 858805b336be > > ("kbuild: add $(BASH) to run scripts with bash-extension"), which > > inserts the contents of a localversion file in the build directory twice. > > > > [Steps to Reproduce] > > $ echo bar > localversion > > $ mkdir build > > $ cd build/ > > $ echo foo > localversion > > $ make -s -f ../Makefile defconfig include/config/kernel.release > > $ cat include/config/kernel.release > > 5.4.0-rc1foofoobar > > > > This comes down to the behavior change of 'local' variables. > > > > The 'man sh' on my Ubuntu machine, where sh is an alias to dash, > > explains as follows: > > When a variable is made local, it inherits the initial value and > > exported and readonly flags from the variable with the same name > > in the surrounding scope, if there is one. Otherwise, the variable > > is initially unset. > > > > [Test Code] > > > > foo () > > { > > local res > > echo "res: $res" > > } > > > > res=1 > > foo > > > > [Result] > > > > $ sh test.sh > > res: 1 > > $ bash test.sh > > res: > > > > So, scripts/setlocalversion correctly works only for bash in spite of > > its hashbang being #!/bin/sh. Nobody had noticed it before because > > CONFIG_SHELL was previously set to sh only when bash is missing, which > > is very unlikely to happen. > > > > The benefit of commit 858805b336be is to make people write portable and > > correct code. I gave it the Fixes tag since it uncovered the issue for > > most of people. > > > > Clear the variable 'res' in collect_files() to make it work for sh > > (and it also works on distributions where sh is an alias to bash). > > > > Fixes: commit 858805b336be ("kbuild: add $(BASH) to run scripts with bash-extension") > > Reported-by: Geert Uytterhoeven > > Can you please use > > Reported-by: Geert Uytterhoeven > > instead? OK, I will. Thanks. > > Signed-off-by: Masahiro Yamada > > Thanks, that fixes the issue for me! > > Tested-by: Geert Uytterhoeven > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds -- Best Regards Masahiro Yamada