Received: by 10.223.176.5 with SMTP id f5csp1551835wra; Wed, 7 Feb 2018 22:52:11 -0800 (PST) X-Google-Smtp-Source: AH8x2261p6TAF/lpciswYmxBKX0i9DAYEMcjO8vqtF+Bg7g6EX0zY0DiowjcUU6CVEN7Wux4xs1X X-Received: by 2002:a17:902:60c7:: with SMTP id k7-v6mr5111554pln.316.1518072731771; Wed, 07 Feb 2018 22:52:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518072731; cv=none; d=google.com; s=arc-20160816; b=zdejKnd3qbpcU01vDeaePqI4ftXxp4BKmV8Jw8muy+DdIU/7tYf0/zhbUKa3YtIiAz sfkDTHcPSmFH8jQ3thHjejcgviluo1IcauDbdoTS/s1METIk5idR+ytUz4v0LC4mRG7R pNmPjgd3DRk7LNsLGSlzeb9tqU8L0tluRjIw+roDkL4/DfiDbxHcpg7+Vv93X2pyIfYV MqNOW76Euz51I4QhVBFIYG6ch8Ko0sUlKpclkS+AzU8GxDTjcBQEtyD4SX4CyycXC9kp fj0FZh9Su6b/8OrKShGvxSTvt8JpscemjFDEjUadC6Iz4KcOT3bcO73+P0A6DQSE64sS HFaA== 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=5ssRrwSls9qkZaQurVefB4Ou/TESAMUDX870SovZXp0=; b=qKBAdUYahXcpzkY5B6ocu5/IhkQ3RRzubYFDq1C94X/5GgZwxludOsr6mgKOeOuj9G E+Bg9jcYL+zd080wX54g/zSmyIicZJzRnzXdRObIusG96rNav4wwaudkgBFmNj2ps/0N 3lLbyfZRFAMzY6EYHahwsSfBBd06Jm6dIGwTJKXkJxWtUJWY4mmJARI0oTmTFUaTzEMT IOAAegUWedNxI1K+KFXLmjuskJybYkrKVHlzMvdAls5LD2FxC59NTqeowqji+DMBr0k0 nWI+IVAup5fO+uGcuE4TFPyYHBL95gMqgBxuqA1EfeXFKNFeO8PBN7ZYdEQN+9qQ0Jxg 3zFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SlKrRtN7; 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 bd1-v6si2357294plb.69.2018.02.07.22.51.57; Wed, 07 Feb 2018 22:52:11 -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=SlKrRtN7; 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 S1750914AbeBHGvW (ORCPT + 99 others); Thu, 8 Feb 2018 01:51:22 -0500 Received: from mail-vk0-f67.google.com ([209.85.213.67]:36762 "EHLO mail-vk0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750766AbeBHGvU (ORCPT ); Thu, 8 Feb 2018 01:51:20 -0500 Received: by mail-vk0-f67.google.com with SMTP id m197so2134927vka.3; Wed, 07 Feb 2018 22:51:19 -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=5ssRrwSls9qkZaQurVefB4Ou/TESAMUDX870SovZXp0=; b=SlKrRtN73CsQ1fymeh3n7HlQbcQKLQX1/w5YPERvAtSUTGNEG6tXg46q/RgXWVBS3Y mmopJEdltYpBrn3sYbP57HXnOUgFQQWUIl6YxYzI1xP5WynqDrWKSdafOF0FRApPYahP 37CCQgw30uotAhMXumuoE2vx0h/fbIVEr6U6hac4tqq+lbfhnq8piqqNhLJ9CTm93HC+ WG9NdFesndz1fUgGA4W1Iixh4R5cDpPUa/so1lzKTqWppkwO4UDJEBBwk/uMRoEJdRk9 fZ+X/hf66VgDrhGjfuiqMdKuhkGPiRSk1Le1zdE2R4DJdhD5/tXzhHO/cNxHv/R/ZF6x 6sIw== 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=5ssRrwSls9qkZaQurVefB4Ou/TESAMUDX870SovZXp0=; b=WBgRiuQ/0DsIOiSAgg7XZnOt16wzbRipl2RfaJ/4soUxoB7t4+kVip50lZi857/4Hv fgjnZskC9+uEa74HSQVpCyuofmnfh0jnAcb0j0U6mAZ33Fn8HJwXikRnMH/YZtjaBMhm /gSEUgAVQVdXkCuUtwjqKRuHVky7ypd+a4khQszadJo642HEXyx/5jErP1ZHqNQ9nXy0 MIEjou0ZbbGdhIYvQYmU6HIS7EtIv91bKoUgdaZdBt9RdSBW2y2aq1kwo7EB4FHkUC6r DM9gDoRlr7FTUgoKxehtCpZW8HSS2egQU6TkvkoEUYH6QDTf0vTuQ24EwvOgR6Xgnx48 PqNA== X-Gm-Message-State: APf1xPDTzEp3GTMVrQs4MZgxhkFjkg93A4r08+WLF6HeNXHU0+Ecs9jb 9p9NQMTzd6/FaG731eie46sf4a+67PHOevneTag= X-Received: by 10.31.181.69 with SMTP id e66mr7039003vkf.122.1518072679517; Wed, 07 Feb 2018 22:51:19 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.70.21 with HTTP; Wed, 7 Feb 2018 22:51:19 -0800 (PST) In-Reply-To: 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:51:19 +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 7:35 AM, Ulf Magnusson wrote: > 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 Hmm... if stdout is a tty and stdin isn't, this would prevent the input from showing up on the terminal though, so I guess it makes sense. That case seems more important than the weird stdin=tty/stdout=file case. Tricky stuff. :) Cheers, Ulf