Received: by 10.223.185.116 with SMTP id b49csp3342276wrg; Sun, 18 Feb 2018 20:52:06 -0800 (PST) X-Google-Smtp-Source: AH8x227Fc/HAKD2AWWDHvh7iL08qXlX04cTpWKa6MW5C5CecdqdJkljjoLbwvedA/5+MbijVYHIx X-Received: by 10.99.160.80 with SMTP id u16mr11187885pgn.389.1519015926437; Sun, 18 Feb 2018 20:52:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519015926; cv=none; d=google.com; s=arc-20160816; b=G2EtC2fj/zih883Sgi8NGAiCp7262n6w9bxPMtoWS4LZ09l7AIBrTaDOWobkrFbnsc x2J+/EPbjW0eg7PzTQNNwpztSEIlyB00LN0G+k8SuzF+h02rQNkE14MH6YLZLo9U4aRS I3R9uua/dBEO0Ejk3cnHCGRnJ32DNOR/wsH5704FRCXPN1o9zapy8jak1Z8PMJHwszDI m6r5rQZqHjX0JTqSk1/FcYetxuJ7S3iqUDCemre+eRgo0DW40/TxG02ZjgvSyi9uguZc UMUI2FoF0hpfVAEnFT2aVz2Op3u+kGcvkgjAZYLNisXcdZtAO0eAue2LYtj7at2MZhp5 NuuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=sdsAtKl+3dmVISj2FfUJlo5RC3PEbBp+BpPq28iHdno=; b=HsAJFTOZj00bq6t+lcvaI97+kEYP6iGK97ET+Pg4rymByeGVMNs5U/J8LE7ZsSO5xP bzfYZg0skTO/SBMvyNKBL0/86xLN0kc3fW2VNSChXVLEdfkXYM4uOOwi4DeKgjRDi8xw Pyx+V1o+gmYr6cVgJ/ZzIM+YCKumdyvq8qPdb0hIxvxtxIz9c8w1LiwYsYuuxS0Aobp0 rue22Kgq6GTryJuLzRRU9SNWODYysLqSwXdbIHUk9UcEscDZfjSAkMk4XJb2kURLZeqw wKEpUyi0yHECV+usUiFq0fcuC/KcdttuNv9TE+PIR++Lq50qFfTdV5mQoc0FVW1+6F+/ V/2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WrCo0RFC; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13si694434pgc.75.2018.02.18.20.51.13; Sun, 18 Feb 2018 20:52:06 -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=@gmail.com header.s=20161025 header.b=WrCo0RFC; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751962AbeBSEtC (ORCPT + 99 others); Sun, 18 Feb 2018 23:49:02 -0500 Received: from mail-lf0-f54.google.com ([209.85.215.54]:43535 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751893AbeBSEtA (ORCPT ); Sun, 18 Feb 2018 23:49:00 -0500 Received: by mail-lf0-f54.google.com with SMTP id q69so11296212lfi.10; Sun, 18 Feb 2018 20:48:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sdsAtKl+3dmVISj2FfUJlo5RC3PEbBp+BpPq28iHdno=; b=WrCo0RFC22JxCVm5BHy04OXLkmTGQMATeccRLs4BIKFT2p0S70+pKkSmK6krflrb2v fsvzWqWzkk8vh31RCfRjF/3fv8UIRL8dZ/z7AGI2HGB/GldVARp2LGP4FSElGCY2bTx6 N9Myx7+K2m2xmcSj80jLp8EBdxrE2eA/mTRB7l2qrGE4bNS6XmGuiIcxsWLdr1LB19M/ L/zNLM9Tn21As+ogxhjhgezpAnDmgOl1aqRiB3GnU9Jq/FjDydxrxr5TwrmF4Zi1mMO7 rVjxZMFvseBeTSuB9AtLtR2Psbj+NDSqIdo/3r2trcVNyA4gmtRqKDSk0lcowYdZTO6l GD9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=sdsAtKl+3dmVISj2FfUJlo5RC3PEbBp+BpPq28iHdno=; b=eW/Ufyza70RX7qIfSriwuLG1pKwoNTPGEo2/xOST+Gr4VuZnBlW28oos5HNLHBLqGw 8lZvcl5m3I+r/4er8dW7SBqOwBP5E1WAoVQNo3UZbljbqtyTZh+k0myzqIu/lZ2Yx94s nWCzPb0KW+QliPZAqZBjQlaO6YybyQqVDIy3d35p5NNjsuGmiKAsqhJk3X3u0MemvI/r JswH1UXFcjeTgXv3rTPqnDlacmZTUXFvTiQIstFqcYHZB+SUdU9rfhZgIDw11N7hy1MX Ivy++l8wSylufE4Vb/7oaBl8unEbHmspeuyYdju9MNira0SzhmrJTIqKVdXg/eLphOaZ +DnA== X-Gm-Message-State: APf1xPAMw1lbHckBNgVukuSohkm/gS7og4BfEOcU8V9iMTQ4LrTG5iBV kr6zvy9IFfkz/TYANXgF/b8= X-Received: by 10.46.93.148 with SMTP id v20mr8220454lje.34.1519015738589; Sun, 18 Feb 2018 20:48:58 -0800 (PST) Received: from huvuddator (ua-213-113-106-221.cust.bredbandsbolaget.se. [213.113.106.221]) by smtp.gmail.com with ESMTPSA id i6sm4651315lji.26.2018.02.18.20.48.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 Feb 2018 20:48:57 -0800 (PST) Date: Mon, 19 Feb 2018 05:48:45 +0100 From: Ulf Magnusson To: Linus Torvalds Cc: Masahiro Yamada , Linux Kbuild mailing list , Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Sam Ravnborg , Michal Marek , Linux Kernel Mailing List Subject: Re: [PATCH 11/23] kconfig: add 'shell-stdout' function Message-ID: <20180219044845.7cnqpgyiinn6hkyb@huvuddator> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> <1518806331-7101-12-git-send-email-yamada.masahiro@socionext.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 16, 2018 at 11:17:52AM -0800, Linus Torvalds wrote: > On Fri, Feb 16, 2018 at 10:38 AM, Masahiro Yamada > wrote: > > This is the second built-in function, which retrieves the first line > > of stdout from the given shell command. > > This is the only part I really don't much like in your patch series. > > Most of it is just lovely and looks very nice and powerful, but the > difference between "$(shell ..." and "$(shell-stdout ..." to me is > bvery ugly. > > Can we *please* make "shell-stdout" go away, and make this just be "shell"? > > The rule would be very simple: > > - if the result of the shell command is a failure, the result is 'n' > > - otherwise, the result is the first line of stdout > > - if the result is empty, we replace it with 'y'. > > So doing $(shell true) would be 100% equivalent to $(shell echo y), > and you could still do that > > default $(shell $CC --version | grep -q gcc) > > because it would just automatically do the right thing. > > Basically, the only difference is how $(shell ) works in the success > case: the result won't necessarily be 'y', it will be whatever output. > But if you want to always turn it into 'y' (say, you don't have a "-q" > flag for the grep equivalent above), you can always do so with > > default $(shell $CC --version | noqgrep gcc > /dev/null) > > So it seems to me that there is never any fundamental reason why we'd > want both "shell" and "shell-stdout", since "shell-stdout" is > fundamentally more powerful than "shell", and can always be used as > such (and just renamed to "shell"). > > Because I really think that it's just much prettier and more intuitive > to be able to say > > default "/boot/config-$(shell uname --release)" > > without that "-stdout" thing. > > Hmm? > > But I do want to say how much I liked this series. Just this part > seemed to result in uglier Kconfig scripts. > > Linus Could there be cases where you'd legitimately want to put empty output from a command in a string (that would be common enough to matter)? That'd get messier with the above rule, as it never generates an empty string as output. For an environment variable, stuff like prefixes come to mind, but I can't think of anything for a command. I'm more familiar with Kconfig than the rest of the kernel build system though. Would you still be as opposed (or more opposed...) to having two functions if they were called something like 'success' and 'stdout' instead? This reads pretty naturally to me: config CC_IS_GCC def_bool "$(success $CC --version | grep gcc)" As does this: default "/boot/config-$(stdout uname --release)" The rule for $(success ...) would be that it's textually replaced by "y" if the exit status of the command is 0, and with "n" in all other cases. $(stdout ...) would be textually replaced by the first line from stdout. Maybe it'd be helpful to spit out a warning if the exit status is non-0. All functions would just do dumb and simple-to-understand text replacement, and all the interpretation would happen later in the normal way. Enforcing the quotes would make this behavior obvious. That would indirectly turn the expanded values into constant symbols internally in Kconfig. Thoughts? Cheers, Ulf