From: Thibault Godouet Date: Sun, 26 Jun 2016 17:43:19 +0000 (+0100) Subject: boot-install: added missing ask_user() (lost in merge?) X-Git-Tag: ver3_2_1 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Ffcron-3.2;p=thirdparty%2Ffcron.git boot-install: added missing ask_user() (lost in merge?) --- 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