common.sh: drop unused interactive code
The last user of this was removed in CL:1079859, so drop it too.
BUG=chromium:844646
TEST=precq passes
Change-Id: Ia281f02c077f9fa683434266dfad0f1b6e33ffcb
Reviewed-on: https://chromium-review.googlesource.com/1483762
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
diff --git a/common.sh b/common.sh
index 304ae27..b18343d 100644
--- a/common.sh
+++ b/common.sh
@@ -1215,110 +1215,6 @@
}
}
-# Checks that stdin and stderr are both terminals.
-# If so, we assume that there is a live user we can interact with.
-# This check can be overridden by setting the CROS_NO_PROMPT environment
-# variable to a non-empty value.
-is_interactive() {
- [[ -z ${CROS_NO_PROMPT} && -t 0 && -t 2 ]]
-}
-
-assert_interactive() {
- if ! is_interactive; then
- die "Script ${0##*/} tried to get user input on a non-interactive terminal."
- fi
-}
-
-# Selection menu with a default option: this is similar to bash's select
-# built-in, only that in case of an empty selection it'll return the default
-# choice. Like select, it uses PS3 as the prompt.
-#
-# $1: name of variable to be assigned the selected value; it better not be of
-# the form choose_foo to avoid conflict with local variables.
-# $2: default value to return in case of an empty user entry.
-# $3: value to return in case of an invalid choice.
-# $...: options for selection.
-#
-# Usage example:
-#
-# PS3="Select one [1]: "
-# choose reply "foo" "ERROR" "foo" "bar" "foobar"
-#
-# This will present the following menu and prompt:
-#
-# 1) foo
-# 2) bar
-# 3) foobar
-# Select one [1]:
-#
-# The return value will be stored in a variable named 'reply'. If the input is
-# 1, 2 or 3, the return value will be "foo", "bar" or "foobar", respectively.
-# If it is empty (i.e. the user clicked Enter) it will be "foo". Anything else
-# will return "ERROR".
-choose() {
- typeset -i choose_i=1
-
- # Retrieve output variable name and default return value.
- local choose_reply=$1
- local choose_default=$2
- local choose_invalid=$3
- shift 3
-
- # Select a return value
- unset REPLY
- if [[ $# -gt 0 ]]; then
- assert_interactive
-
- # Actual options provided, present a menu and prompt for a choice.
- local choose_opt
- for choose_opt in "$@"; do
- echo "${choose_i}) ${choose_opt}" >&2
- : $(( ++choose_i ))
- done
- read -p "$PS3"
- fi
- # Filter out strings containing non-digits.
- if [[ ${REPLY} != "${REPLY%%[!0-9]*}" ]]; then
- REPLY=0
- fi
- choose_i="${REPLY}"
-
- if [[ ${choose_i} -ge 1 && ${choose_i} -le $# ]]; then
- # Valid choice, return the corresponding value.
- eval ${choose_reply}=\""${!choose_i}"\"
- elif [[ -z ${REPLY} ]]; then
- # Empty choice, return default value.
- eval ${choose_reply}=\""${choose_default}"\"
- else
- # Invalid choice, return corresponding value.
- eval ${choose_reply}=\""${choose_invalid}\""
- fi
-}
-
-# Display a prompt that asks the user to choose yes or no.
-# $1 - The prompt to be displayed to the user, with " [y/N]: " appended.
-#
-# Usage example:
-#
-# prompt_yesno "Would you like a cup of tea?"
-#
-# The function will return 0 for yes and 1 for no, appropriate for using
-# in an if statement or loop.
-prompt_yesno() {
- local prompt=$1
- local reply
-
- assert_interactive
- read -p "${prompt} [y/N]: " reply
-
- # Be strict. No is the default.
- if [[ "${reply}" != y && "${reply}" != Y ]]; then
- return 1
- fi
-
- return 0
-}
-
# Display --help if requested. This is used to hide options from help
# that are not intended for developer use.
#