Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp15153044ybl; Tue, 31 Dec 2019 02:29:03 -0800 (PST) X-Google-Smtp-Source: APXvYqxirgtvMYbmB5YCCr1UW5g6LVQPjCoMJhSdgDNMJssGBVDAzeZLa72ZiYrs6CvyT53j2VFG X-Received: by 2002:a05:6830:1199:: with SMTP id u25mr75151589otq.344.1577788142923; Tue, 31 Dec 2019 02:29:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577788142; cv=none; d=google.com; s=arc-20160816; b=EvNXdYd6qFAB1JAuC59OhQ0hcEvMnqn6JGLF+szbLvPBI9Lx/IkDR9ovf3WIhXuo95 ZWQwmDjSvh5ZQwjY+vylXSMPT3SAnOLTYIexi14F2z4GXD8Sx0NcsBuqYI2l72+sJsTP xlJHrPav+S/aRr8cM2n/f5wb5Pq6Y8iXywd6IqLI7E2kGn4c89ugoICO8ZnoRwsktO1p ktloexZ0KnYcySbkk+Sr1o+fI3SCL/uj1I1DppOW7pg3xnHijrwqMwrYB+JBkaHvEuAP 31QusK+FjerkXwE49kEDN4Oikc5ckiYBs8SC1JX+HmNUvPFNI1mi8HAZ97uVlnxKPHw4 CBbg== 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=SKqd2HWiYAuhUrskiZxzhJITENWtpPCtLPbJtA0qXLI=; b=wLzMfy5FErO6cdqwNSDIN4tKel9qAzgmtMbQYzEGsLdFXGY/i6YSEyQFgs7AQi9AXI 9F1DVhb4WMqmbaxVcGSw9T3UANCa9x2CFNe/orGi2F2KgC1iZUWOeu+r0s8idIKi/ndM fjssf91obPPmUDaskxz96rKm7E9G/54CC7MdUSQT/ODw+/djilmRfR2VE5ely3vuojrH yacmfjn1vRhQHHvJho3O3gvev2AVQPXtDBSYUujXQ62IdIv4E5XZlNvQVqp3Xc6hmEqA 9u/5DvcgPVXtJufh4CEi3dXli1fae3VIXOwuX+K3vjgMbsz6iOv8Si4/q7jKSJ/8XTtb D0bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=0k2D0yKU; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11si14916462oie.231.2019.12.31.02.28.49; Tue, 31 Dec 2019 02:29:02 -0800 (PST) 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=0k2D0yKU; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726674AbfLaK2H (ORCPT + 99 others); Tue, 31 Dec 2019 05:28:07 -0500 Received: from conssluserg-06.nifty.com ([210.131.2.91]:40722 "EHLO conssluserg-06.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726421AbfLaK2H (ORCPT ); Tue, 31 Dec 2019 05:28:07 -0500 Received: from mail-ua1-f51.google.com (mail-ua1-f51.google.com [209.85.222.51]) (authenticated) by conssluserg-06.nifty.com with ESMTP id xBVARwPb011363; Tue, 31 Dec 2019 19:27:58 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com xBVARwPb011363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1577788079; bh=SKqd2HWiYAuhUrskiZxzhJITENWtpPCtLPbJtA0qXLI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=0k2D0yKUBflnAlvgsKjVwi17UJdPPrfQ9WzdIgNx8/1LXbovH/qKPkqAmnkwKpvz5 PyTfrB50i2jtzGgr6RQbOjXUGVxHfGbb9LQPUsQZBniP2OmbJUqAzlpi6m6gqRLQat BqJ/KSGuaOi6AGeBL+UY6HO/j4tCh1A/PatYd+9JhbUfiCbTGzAhrNW7YmxQkZ/Ah2 W/4bdCXIqxa8b6Y3o/2dLGGoCn+1fo8RxuYIji8+sIZj+7Z0wZKI/5t8Xnov42GSod HUEu3v5R41JUTzwnCAPbBia+Ogw1U9P37iArzA51r0X/iCOCA32SrQa4I6G5c4hVwB 7lBcFRTZMRqKA== X-Nifty-SrcIP: [209.85.222.51] Received: by mail-ua1-f51.google.com with SMTP id c14so10788425uaq.11; Tue, 31 Dec 2019 02:27:58 -0800 (PST) X-Gm-Message-State: APjAAAXhsKb3whrY7Xtfn7MeK3UWNSZDXw4kUromuySP0PcczI62ef09 bDaZc4zBqA0cr43AJoIykUrwwFCB4hIHzUhbpdo= X-Received: by 2002:ab0:2ea6:: with SMTP id y6mr21100400uay.25.1577788077465; Tue, 31 Dec 2019 02:27:57 -0800 (PST) MIME-Version: 1.0 References: <20191230132006.7401-1-masahiroy@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Tue, 31 Dec 2019 19:27:21 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] initramfs: fix 'bad variable name' error in gen_initramfs_list.sh To: Justin Capella Cc: Linux Kbuild mailing list , "Jory A . Pratt" , LKML 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 Tue, Dec 31, 2019 at 12:13 AM Justin Capella wrote: > > I was looking at this, and in theory there are other problems that > could arise from non-escaped characters, or things with leading > hyphens... In general it isn't great to assume ls output will play > nicely with the internal field separator / IFS. I think a better > solution would be to use something like ${foo@Q} and instead of trying > to scrape ls -l, maybe using stat, since it can be asked to print out > the device number. I am not sure if 'stat' is necessarily preferred over 'ls -l'. Commit a670b0b4aed129dc11b465c1c330bfe9202023e5 says 'stat' is not standardized. There is some room for argument how far we should care about the portability, though. > > But I don't think this patch fixes the problem mentioned at all-- I > think the problem is initfs is not a variable name on line 61: cmd_initramfs is defined at line 46. Look into scripts/Kbuild.include if you want to know how if_changed works. > $(call if_changed,initfs) > > https://github.com/torvalds/linux/blob/351c8a09b00b5c51c8f58b016fffe51f87e2d820/usr/Makefile#L61 > > The Makefile and script look like more patches would be needed to fix > mentioned issue, and I'm kind of wondering what the intent behind > lines 31-32 is... > > ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \ > $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d) > > why filter nothing, why shell echo? It does filter "", which is different from nothing. You need to notice GNU Make handles double-quote (") as a normal character. There is no special meaning as it has in shell. 'echo' is used just for ripping off the double-quotes. > > Quoting and/or proper escaping would be needed in many other places, > and I suspect cpio input is always regenerated... I do not think so. If the cpio input is regenerated, the following log is shown. GEN usr/initramfs_data.cpio I do not see it every time. > The use of sed to > manually escape things and suggesting using \ instead of using the > argument terminator "--"... If weird paths with spaces and stuff are a > requirement for the script needs some overhauling If you find a problem in particular, a patch is welcome. But, what you stated above comes from your misunderstanding. > On Mon, Dec 30, 2019 at 5:21 AM Masahiro Yamada wrote: > > > > Prior to commit 858805b336be ("kbuild: add $(BASH) to run scripts with > > bash-extension"), this shell script was almost always run by bash since > > bash is usually installed on the system by default. > > > > Now, this script is run by sh, which might be a symlink to dash. On such > > distros, the following code emits an error: > > > > local dev=`LC_ALL=C ls -l "${location}"` > > > > You can reproduce the build error, for example by setting > > CONFIG_INITRAMFS_SOURCE="/dev". > > > > GEN usr/initramfs_data.cpio.gz > > ./usr/gen_initramfs_list.sh: 131: local: 1: bad variable name > > make[1]: *** [usr/Makefile:61: usr/initramfs_data.cpio.gz] Error 2 > > > > This is because `LC_ALL=C ls -l "${location}"` contains spaces. > > Surrounding it with double-quotes fixes the error. > > > > Fixes: 858805b336be ("kbuild: add $(BASH) to run scripts with bash-extension") > > Reported-by: Jory A. Pratt > > Signed-off-by: Masahiro Yamada > > --- > > > > usr/gen_initramfs_list.sh | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/usr/gen_initramfs_list.sh b/usr/gen_initramfs_list.sh > > index 0aad760fcd8c..2bbac73e6477 100755 > > --- a/usr/gen_initramfs_list.sh > > +++ b/usr/gen_initramfs_list.sh > > @@ -128,7 +128,7 @@ parse() { > > str="${ftype} ${name} ${location} ${str}" > > ;; > > "nod") > > - local dev=`LC_ALL=C ls -l "${location}"` > > + local dev="`LC_ALL=C ls -l "${location}"`" > > local maj=`field 5 ${dev}` > > local min=`field 6 ${dev}` > > maj=${maj%,} > > -- > > 2.17.1 > > -- Best Regards Masahiro Yamada