From 5c68a94ab0f8a0b69d3506c612f0b22c0f4ed9f6 Mon Sep 17 00:00:00 2001 From: Thibault Godouet Date: Sun, 26 Jun 2016 18:43:19 +0100 Subject: [PATCH] boot-install: added missing ask_user() (lost in merge?) --- script/boot-install | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/script/boot-install b/script/boot-install index f8e2360..93c2cf5 100755 --- a/script/boot-install +++ b/script/boot-install @@ -31,9 +31,32 @@ DESTBIN=$2 DEBUG=$3 #DEBUG=1 FCRONTABS=$4 -ANSWER=$5 +ANSWER=$5 # Automatic answer: 0->no, 1->yes, 2->ask SRCDIR=$6 +# Return y or n (defaults to y) +# (uses the automatic answer if appropriate) +ask_user() { + if test "$ANSWER" -eq 1 ; then + echo y + elif test "$ANSWER" -eq 0 ; then + echo n + fi + + # If we get here, then ask the user interactively + ANS= + while test \( "$ANS" != "y" \) -a \( "$ANS" != "n" \) ; do + echo -n "Please answer with 'y' or 'n' (default: 'y'): " >/dev/stderr + read ANS NOTHING + test -z "$ANS" && ANS=y # Default value + done + echo $ANS + +} + +# Validate the command line arguments: +# FIXME + if test $DEBUG -eq 1; then STARTCMD="fcron -b -d" else -- 2.47.2