From mboxrd@z Thu Jan 1 00:00:00 1970 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 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-Message-ID: From: rsiddharth Date: Thu, 8 Nov 2018 23:13:01 -0500 Message-Id: <20181109041301.39042-1-s@ricketyspace.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 33134@debbugs.gnu.org Cc: rsiddharth 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(-) -- 2.19.1