diff --git a/server-install.sh b/server-install.sh index edd33c6..4b4d728 100755 --- a/server-install.sh +++ b/server-install.sh @@ -50,11 +50,11 @@ fi TTY= if (: /dev/null; then TTY=/dev/tty; fi -# ask VAR "question" default: the answer from the terminal, else the -# environment's LPRA_, else the default. +# ask VAR "question" default [KEY]: the answer from the terminal, else the +# environment's LPRA_ (KEY is VAR if not given), else the default. ask() { - var=$1 q=$2 def=$3 - eval "env=\${LPRA_$var:-}" + var=$1 q=$2 def=$3 key=${4:-$1} + eval "env=\${LPRA_$key:-}" [ -n "$env" ] && def=$env ans= if [ -n "$TTY" ]; then @@ -64,11 +64,11 @@ ask() { [ -n "$ans" ] || ans=$def eval "$var=\$ans" } -# confirm VAR "question" y|n: true for a yes. +# confirm KEY "question" y|n: true for a yes (LPRA_ without a terminal). +# The answer stays apart from the script's own variables of that name. confirm() { - ask "$1" "$2 (y/n)" "$3" - eval "v=\$$1" - case "$v" in [yYдД]*) return 0 ;; *) return 1 ;; esac + ask _yn "$2 (y/n)" "$3" "$1" + case "$_yn" in [yYдД]*) return 0 ;; *) return 1 ;; esac } # ---------- download ----------