Received: by 10.223.176.5 with SMTP id f5csp1512209wra; Wed, 7 Feb 2018 21:59:39 -0800 (PST) X-Google-Smtp-Source: AH8x226Y811RNn6Ifrp1K3uCUNA+HUepXsszChEktNkKRnQerx7j8AYB0tHJKK0vKs87uj1dZ3Ry X-Received: by 10.98.255.26 with SMTP id b26mr3904004pfn.177.1518069579184; Wed, 07 Feb 2018 21:59:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518069579; cv=none; d=google.com; s=arc-20160816; b=ybfcT4Ese9jI/+wY21b/J8gj+L/cGj3tUYC47yRmY8k9wbbxO/Grbky85xdcoZNT4w EEClGPJ/qlKUrGzSfIirwzXP54Tw9pdXtVL7bqxFkKymSu+9M6Gb39xpDrscUNayLmrt LzEVFYAo/XwTtXyq4Lmk+bqmkbIyb+Op8JsXxk4Nvj362tRP+QSSnxLj8nUefyPEbyax PEmHC8s9SulzR59ZN90xf9TAY7aB35amTwujcMq0Q16G2sJ09QOJSd0gAnCJ2Vxw70Ba G6eE8SNq7NADQDS1utWRyK9VQC8uPYM0Gnbv7dHH9cwZKtis6mbqNuh5d0q2M/jDQWDy rHpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=tkKVsyCnE1leUCGtzur2BHn/LVrjjGUZyjSnZS+mtAI=; b=AxQjHm1asimcMeINo31UArNtue/ucyMYH92MVPeQL0oSbkF2hDc+4aZN4LiOuiogzr qEUnOuT8ggz69kxO4iBGFT11TxUHXro4oDXs8q48eT2hpBrx8WXauG3g59ubuT0dOg2h SV1ScEX1CPuaBqJY5Z0cY2cGq5IlmozP3s58voRW1m1olgPDetIU2Gpcp7ha2D7rPdCd IMht+o4GYjVcuP3Y3VRqse3w9DCLdU1oWdfJldNXBXC7NojMMdKMYPnuUYqAyLQro/TZ Y53XGeYWKT8+5/vVSF1LiciLbVwsv+O6ErsEo8ToODi3GIMkeJ8kOOsvGE0zjWr8giFP nYJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=c3msDm8J; 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 a25si2306032pfg.10.2018.02.07.21.59.25; Wed, 07 Feb 2018 21:59:39 -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=c3msDm8J; 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 S1751974AbeBHF6I (ORCPT + 99 others); Thu, 8 Feb 2018 00:58:08 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:58454 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750954AbeBHF6E (ORCPT ); Thu, 8 Feb 2018 00:58:04 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id w185uhG3007816; Thu, 8 Feb 2018 14:56:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w185uhG3007816 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518069405; bh=tkKVsyCnE1leUCGtzur2BHn/LVrjjGUZyjSnZS+mtAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c3msDm8Js4ECoMciy9eOsjrOtg0nnn+J7NA9CHYHuhrfKfl6p/XbG6rP2wbp8T/2k C6dfCv4+KNHqAtOJPaepYM/EoHJrqII0OI1iKHhpOnoPUyAJ+ao4TmPavAMdIdsseX PcRUrKjaamJvENWmoiHNhkTHdyGqITSQ0j8TiJ5ojHVMY3gAqiJMfSF5l5oEwh4zSp yZDyCrn64QRcZH3f9CQhFqFKGAtoV+tOCt8ZW+npsxxNG+BzkgyYzSTNyiE48psNXQ RFfoLIs385cf7lURNPiyCnlM5zFOf1W3EyLarijirk/eKn0O0/oosd3pCvvocjMzIA D5wvv1HSFcBQw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Michal Marek , Ulf Magnusson , Randy Dunlap , "Luis R . Rodriguez" , Masahiro Yamada , linux-kernel@vger.kernel.org, Marc Herbert Subject: [PATCH 2/2] kconfig: echo stdin to stdout if either is redirected Date: Thu, 8 Feb 2018 14:56:40 +0900 Message-Id: <1518069400-7037-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518069400-7037-1-git-send-email-yamada.masahiro@socionext.com> References: <1518069400-7037-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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