Received: by 10.223.176.5 with SMTP id f5csp1554325wra; Wed, 7 Feb 2018 22:55:51 -0800 (PST) X-Google-Smtp-Source: AH8x226QS6bilbPAlVu68L8AWSO7wG3YfoegVbr6BsYs9QAPmeJ2savUZtOHMy3TGySqGFYqgrFK X-Received: by 10.98.196.204 with SMTP id h73mr8622919pfk.143.1518072951129; Wed, 07 Feb 2018 22:55:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518072951; cv=none; d=google.com; s=arc-20160816; b=jOCwRJrJys+TY5d9cNPMH2HQ4AccA8hthZZhOazSEF/o21foBzqj2S444GivpYljkf r0D67mT8CLhL5vn9aO9yDwcKbVzVSFTyDdy6BvOFT1IO1HVPp9/40awUTOUrVt+0KvKB xsPOM0NC9YTZ38V4Bsc1v2xjyFK6NJt81tOVmMPUC+gNAvDZh3WJHTom8xyzFdYfbmoY H0y29Mhyj3q8478dhcDVx3Y5MuCM/AMUvdko2rvbKupsLS+X/iPsEVBg/VZjiQCbR+Ue tfdaspD690w0X75LvbK0+hPE+/SnY0PpXeFra6fiTFdXNXpLWrT8pdAHpqwM2J6Pipa2 A5Cg== 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:dkim-filter :arc-authentication-results; bh=sefiEM3JBoLellQZzBQtv2O8x6WpiLkBwYamOORAADA=; b=foSwdxbhRVSHZ361yvWJzyYj7vG4eE0B97Jv5qdg4LtOy+wybDlPPQRzBzX0oM6aPK LNnJPvaaGbKxoHVBLkKiKn5iYt8xIl97xHFhnDMIMhtTVhnZeS2lwdjFqxVWrsgO/jz0 S/ln8xwyY4s+HCJjN6F0hGocr55y0NXEqnv+yOrnAjJWfUXk+5+0Lb7FdqFgOPBP7yKm oov0ekgM1GuqtwsSFiiSfADrTu92CmnBLtVQO4319OXt7LIVyO0DX7zl/UL/2qlGO8g5 V945CShuXddn/zGDXhWgygc3EpuSLEuozWiGr4MZkNSMQsC24InxJpYHQC2JuRC5SRIP wfjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=qMmZngeO; 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 f35-v6si1108799plh.424.2018.02.07.22.55.36; Wed, 07 Feb 2018 22:55:51 -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=qMmZngeO; 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 S1750873AbeBHGy5 (ORCPT + 99 others); Thu, 8 Feb 2018 01:54:57 -0500 Received: from conssluserg-05.nifty.com ([210.131.2.90]:45614 "EHLO conssluserg-05.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750766AbeBHGy4 (ORCPT ); Thu, 8 Feb 2018 01:54:56 -0500 Received: from mail-vk0-f49.google.com (mail-vk0-f49.google.com [209.85.213.49]) (authenticated) by conssluserg-05.nifty.com with ESMTP id w186scba031868; Thu, 8 Feb 2018 15:54:38 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com w186scba031868 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518072879; bh=sefiEM3JBoLellQZzBQtv2O8x6WpiLkBwYamOORAADA=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=qMmZngeOgU4TcRZXF9asehCmL/rBW0xHEHfKANM897wig2SkPS5aQeuu2bXksWLXY w+jPr30Snpm+NJaqFx2zXeVWjTr/SzQgRP2E7NAJuUfMNwEEhoD5PADmU1lQM+3TD2 KyaO37wRDUYAq4Roc/3mF/YF8uXKMATZQVUND+qmphEnRqoJrWRMgJYnWCRAA+erD9 ysPy4LdJltdMRHe/ClPjvKiQXc/tzNIDfONiZTTdQM9enj98eZqmwIXd1SCt1GMGHb iOb8aYx4de8dS/IA2cqsphbfb8fCIyFdZd7+zZZorTj3oaIghlHlhurQraJyL31myD UleTNU4dbCfGQ== X-Nifty-SrcIP: [209.85.213.49] Received: by mail-vk0-f49.google.com with SMTP id f186so2139547vkc.1; Wed, 07 Feb 2018 22:54:38 -0800 (PST) X-Gm-Message-State: APf1xPDSIoSvwdt8n04ioBbszJsWiar/xZ4CY9VSNGic4ZdYEJnug5pN Z2OkNhRNC3+K9QDmHSxCcKNI1IOTR60gH09cXJE= X-Received: by 10.31.96.206 with SMTP id u197mr804989vkb.55.1518072877607; Wed, 07 Feb 2018 22:54:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.83.212 with HTTP; Wed, 7 Feb 2018 22:53:57 -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: Masahiro Yamada Date: Thu, 8 Feb 2018 15:53:57 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] kconfig: echo stdin to stdout if either is redirected To: Ulf Magnusson 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 2018-02-08 15:51 GMT+09:00 Ulf Magnusson : > 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. Yes. I want to address this case too. Anyway, thank you for checking the details! > That case seems more important than the weird > stdin=tty/stdout=file case. > > Tricky stuff. :) > > Cheers, > Ulf > -- > To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Best Regards Masahiro Yamada