Received: by 10.223.176.5 with SMTP id f5csp1542193wra; Wed, 7 Feb 2018 22:38:27 -0800 (PST) X-Google-Smtp-Source: AH8x224HhRl+LO0hvotUkXxKDe6U3xBvVHiTC12KLk9IMJtr/Lnz+8l7seuuZJ4WVls/GRkJd1i+ X-Received: by 10.101.82.1 with SMTP id o1mr6945488pgp.259.1518071907037; Wed, 07 Feb 2018 22:38:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518071907; cv=none; d=google.com; s=arc-20160816; b=xWHe3NyKXPiO781CowOvcs/YLTsNh515vb+eVo60/5RnPM7SsTAQMCuN5rN33mQnXa GVMc9zBdhXC0RWuc5Eilx0T1MSg57eKuCQ3LKcbfFZuo515Xf3yNXYhPgopKXMkIbzAi HAOwpPksvEpDelz58XHrA6GGv3wMLM2+SK1ktLNL6eo7oA5L7gYMpndwAx9phDi9BUos /ReCrecd0XbeyBxi9MZDVE18WVh7Iks26aPTcR8BlCXlgiGh7+ncUnV03IJwrU6r19DZ t5a3YwDeqf5bLPI/9Ype+somlqf5XuWIX1Bw9jjgI+6nf70QlWV2nGcGwvJY2oFK6w1E h7Tg== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=PGCaIWVvwou8Ttb98ZW3wPxuqDY4axRGm99xolFeZmQ=; b=iyAI+WrUG7y/UxW92NoHSnI5EGVA7061Oemhl0anMXZt0LdiseThzTndptWpdBT0IG v08JtKDN2d6cVbLJLKOIoJ91bC/clNmfKgI1OKAQlFt7JPypwUttgfJBsBDsedYf5R0U 2YGIFlCHu0RSYFfQNyHpkA01gc5lgcR5qS+Etk6yhBXiXqAWLHPDj79jbBI87xdmKclA rtrK1I1F3b1YYuerBxz6bCceeqtfX5CFiUr5LXGfZUXx4JGTzrZt2KmyHv3q80P3teK6 2bVD1n3R/gosq+82SMzHjyzQ2EAO1KuFrDqUwCIdpzwR17WvuEdae/uYFvWVWQGGV9dv +ARA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KAsRK2yK; 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 35-v6si2337578pla.473.2018.02.07.22.38.12; Wed, 07 Feb 2018 22:38:26 -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=KAsRK2yK; 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 S1751175AbeBHGfE (ORCPT + 99 others); Thu, 8 Feb 2018 01:35:04 -0500 Received: from mail-ua0-f195.google.com ([209.85.217.195]:45288 "EHLO mail-ua0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750766AbeBHGfC (ORCPT ); Thu, 8 Feb 2018 01:35:02 -0500 Received: by mail-ua0-f195.google.com with SMTP id z3so2203494uae.12; Wed, 07 Feb 2018 22:35:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=PGCaIWVvwou8Ttb98ZW3wPxuqDY4axRGm99xolFeZmQ=; b=KAsRK2yKKNorePAiZEI5V5y3+mkHdqRuD259rhPTDUI5fzUHJGB5I3SyTySVaJAFBU iOVjnNppFXNZX+dtcZIUW2KKJ9jDK4/H9y+1yT6Q/17UEUCO+b6PZy3K34CGWjMKdpOr 7LFI2U8IMjpz+hRRvXuJW28Z0OJ/sh1WYkzEIFqnNVujBoXW5dnzLRRRFOPYkjv9y/J5 LLlzW7lRXkEnHdoZ+bas3owNHkOhRYnovYAliYzdZ4zXtZvY4/SqMrGfIsjAYNEnDbWa hiaw/mWCHt2v9Ng4OmZZD0SXZ0A7Ikr3kQhIPXt3uur2f8x1FdRFIuuDnlol2zHzhZez AWyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=PGCaIWVvwou8Ttb98ZW3wPxuqDY4axRGm99xolFeZmQ=; b=t2KVBKdJSD2rMGogV8CBlp5seffCm80VYsw96kfLAnO6RiabCkRnDtAo1szUKwroGI STlQVgFK6RuJz7puTFJ+SV0dFozGGXEuA87nAqiT2wgtWScVaE+BDuCxGdhYmKmd39gS g6CnOAyGqz/y9NgqMpHqFcOjV/1XweGfEKEoSFlyfU2pBUnV8S4o8+AFGSfv2JuKtUNI 9koMOlNNxzNKn2Hrc6NSeaB1oMhBekHT1igsbnMJtP+ksSm9D8fPIjk/KabOA0xXsNE6 +kuzi5i+AtfRtDk9LHzOUpCP7APCTH5UPUbIC3gZJgubTMDT3wUUMnVdAFfbM1EJPurM S5RA== X-Gm-Message-State: APf1xPBuhHIS8f9QxP0l7Pmn5hJ/ywDRI45CiBJtVxWASChcacPixo9x ESYUS3CSFWrFxg4pXqiU4WOYOBdZisEe51b6AMs= X-Received: by 10.176.76.93 with SMTP id d29mr95039uag.89.1518071701765; Wed, 07 Feb 2018 22:35:01 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.70.21 with HTTP; Wed, 7 Feb 2018 22:35:01 -0800 (PST) In-Reply-To: <1518069400-7037-2-git-send-email-yamada.masahiro@socionext.com> References: <1518069400-7037-1-git-send-email-yamada.masahiro@socionext.com> <1518069400-7037-2-git-send-email-yamada.masahiro@socionext.com> From: Ulf Magnusson Date: Thu, 8 Feb 2018 07:35:01 +0100 Message-ID: Subject: Re: [PATCH 2/2] kconfig: echo stdin to stdout if either is redirected To: Masahiro Yamada Cc: Linux Kbuild mailing list , Sam Ravnborg , Michal Marek , Randy Dunlap , "Luis R . Rodriguez" , Linux Kernel Mailing List , Marc Herbert 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 Thu, Feb 8, 2018 at 6:56 AM, Masahiro Yamada wrote: > If stdio is not tty, conf_askvalue() puts additional new line to > prevent prompts are all concatenated into a single line. This care > is missing in conf_choice(), so a 'choice' prompt and the next prompt > are shown in the same line. > > Move the code into xfgets() to take care of all cases. To improve > this more, echo stdin to stdout. This clarifies what keys were input > from stdio and the stdout looks like as if it were from tty. > > I removed the isatty(2) check since stderr is unrelated here. > > Signed-off-by: Masahiro Yamada > --- > > scripts/kconfig/conf.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c > index 358e2e4..c5318d3 100644 > --- a/scripts/kconfig/conf.c > +++ b/scripts/kconfig/conf.c > @@ -76,6 +76,9 @@ static void xfgets(char *str, int size, FILE *in) > { > if (!fgets(str, size, in)) > fprintf(stderr, "\nError in reading or end of file.\n"); > + > + if (!tty_stdio) > + printf("%s", str); > } > > static int conf_askvalue(struct symbol *sym, const char *def) > @@ -106,8 +109,6 @@ static int conf_askvalue(struct symbol *sym, const char *def) > case oldaskconfig: > fflush(stdout); > xfgets(line, sizeof(line), stdin); > - if (!tty_stdio) > - printf("\n"); > return 1; > default: > break; > @@ -495,7 +496,7 @@ int main(int ac, char **av) > bindtextdomain(PACKAGE, LOCALEDIR); > textdomain(PACKAGE); > > - tty_stdio = isatty(0) && isatty(1) && isatty(2); > + tty_stdio = isatty(0) && isatty(1); > > while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) { > if (opt == 's') { > -- > 2.7.4 > Reviewed-by: Ulf Magnusson Might be some case I'm not thinking of, but wouldn't it make sense to just check isatty(1) as well? If stdout is a regular file, it seems it'd be nice to have the input appear there, regardless of where stdin is from. Maybe the tty_stdio variable could be removed then as well, replaced with just 'if (!isatty(1))'. Cheers, Ulf