From patchwork Fri Nov 9 04:13:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rsiddharth X-Patchwork-Id: 150 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1A7F2167DF; Fri, 9 Nov 2018 04:14:17 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id D2141167DC for ; Fri, 9 Nov 2018 04:14:16 +0000 (GMT) Received: from localhost ([::1]:60165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKyBU-0007sb-3p for patchwork@mira.cbaines.net; Thu, 08 Nov 2018 23:14:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKyBL-0007sW-9X for guix-patches@gnu.org; Thu, 08 Nov 2018 23:14:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKyBH-0005YO-34 for guix-patches@gnu.org; Thu, 08 Nov 2018 23:14:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:37853) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gKyBG-0005Xs-Ss for guix-patches@gnu.org; Thu, 08 Nov 2018 23:14:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gKyBG-0001ik-F6 for guix-patches@gnu.org; Thu, 08 Nov 2018 23:14:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#33134] [PATCH 0/4] [Refactor 0] Add auto yes/no switch to guix-install.sh References: <20181024001542.16368-1-s@ricketyspace.net> In-Reply-To: <20181024001542.16368-1-s@ricketyspace.net> Resent-From: rsiddharth Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 09 Nov 2018 04:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33134 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 33134@debbugs.gnu.org Received: via spool by 33134-submit@debbugs.gnu.org id=B33134.15417367926550 (code B ref 33134); Fri, 09 Nov 2018 04:14:02 +0000 Received: (at 33134) by debbugs.gnu.org; 9 Nov 2018 04:13:12 +0000 Received: from localhost ([127.0.0.1]:42111 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKyAR-0001hZ-Nb for submit@debbugs.gnu.org; Thu, 08 Nov 2018 23:13:11 -0500 Received: from lyra.ricketyspace.net ([159.89.229.91]:42104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKyAP-0001hR-Nc for 33134@debbugs.gnu.org; Thu, 08 Nov 2018 23:13:10 -0500 From: rsiddharth DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ricketyspace.net; s=mail; t=1541736789; bh=Kfx/GHleTtPYj+ChDk5ICUWVZt3zP/Z6OgHdnLNXbNs=; h=From:To:Cc:Subject:Date:From; b=vMNyQdTGeNzYSSgKp8VzMSb3+xCgvxgcSNm1NTL4gjPGzUeJlcxhzXN+kL/WcoQoD Z7iSAZCzs8MMzMY9blQglwW13XNbtktpjsAvDUvNlmWF3MuEAKhcFXAWW3tWeuoecW yqaqpM+s422cMQ8L05gzvGraJ1CqbkTe4regBF76oic1FA7IwMETsBNkDK6qGLG6ee rc7GoEt3X4LiFmmfzniXlPbrRMHFvD1WHT7INbxV1s10/pd9qZfv1p+NsCqB7X5wYM 30p/0ydzW56ERHCSiAKyp5IF/QZb1iMcCjIcyth+Lb+5BzBoRC3g6eAq4UF1FKiZ6y KRbgtV/Ppw4TQ== Date: Thu, 8 Nov 2018 23:13:01 -0500 Message-Id: <20181109041301.39042-1-s@ricketyspace.net> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: rsiddharth Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Thanks Danny, I've refactored the patch based on your feedack. Danny Milosavljevic wrote: >> + # process -y / -n arg. >> + export AUTO_YN=${1:1:1} >> + if [ -z $AUTO_YN ]; then >> + export AUTO_YN="" >> + fi > Why "export" ? Now all the child processes get it, making their environment > different from before. This makes parse_args have system-wide side effects. Remove the `export`. >> ... >> >> main() >> { >> + parse_args $@ >> + > Should be > > "$@" > >with quotes Done. >> ... >> ... >> https://www.gnu.org/software/guix/ >> EOF >> echo -n "Press return to continue..." >> - read -r ANSWER >> + read -N 1 -r ANSWER > While it's nice for the interactive user, doesn't this break > > yes | ./guix-install.sh > > because now it doesn't wait for the newline? Yes, it would break `yes | ./guix-install.sh`. I've removed `-N 1` from the `read` statement. >> - *) _msg "Please answer yes or no."; >> + *) _msg "Please answer yes or no."; yn="" > Does this make it conditionally interactive? Would it be better to "exit 1" here? When the user is running the script interactively and answers, say "Oui", we arrive at the: *) _msg "Please answer yes or no."; case. After this, we go to the beginning of the loop: [[ -n $yn ]] || read -p "Permit downloading pre-built package binaries from the project's build farms? (yes/no) " yn Since $yn is "Oui" `[[ -n $yn ]]` will evaluate to true, the user won't be prompted again, we'll go back to: *) _msg "Please answer yes or no." and this will repeat infinitely. The `yn=""` was added: *) _msg "Please answer yes or no."; yn="" to reset the value of yn, so that `[[ -n $yn ]]` will evaluate to false and the user will be prompted again for answer. rsiddharth (4): guix-install.sh: Add parse_args. guix-install.sh: Update main. guix-install.sh: Update welcome. guix-install.sh: Update sys_authorize_build_farms. etc/guix-install.sh | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)