clause fixes #16
@@ -247,16 +247,16 @@ function render_answer() {
|
||||
echo -en "${NEWLINE}${RESET}"
|
||||
}
|
||||
|
||||
# Exits non-zero at end of input (Ctrl-D) so the caller can quit
|
||||
# Exits non-zero when input has ended so the caller can quit
|
||||
function retrieve_guess() {
|
||||
if [[ -n $1 ]]; then
|
||||
read -r -p "${CLEAR_UP1}$1: " GUESS || exit 1
|
||||
read -r -p "${CLEAR_UP1}$1: " GUESS || end_of_input
|
||||
else
|
||||
read -r -p "${CLEAR_2END}Enter Guess: " GUESS || exit 1
|
||||
read -r -p "${CLEAR_2END}Enter Guess: " GUESS || end_of_input
|
||||
fi
|
||||
|
||||
while [[ ${#GUESS} -ne 5 ]] || [[ ! "${GUESS,,}" =~ ^[a-z]{5}$ ]]; do
|
||||
read -r -p "${CLEAR_UP1}Must be 5 letters: " GUESS || exit 1
|
||||
read -r -p "${CLEAR_UP1}Must be 5 letters: " GUESS || end_of_input
|
||||
done
|
||||
declare valid_guess
|
||||
validate_guess "${GUESS}" ; valid_guess=$?
|
||||
@@ -278,6 +278,14 @@ function retrieve_guess() {
|
||||
echo -n "${GUESS^^}"
|
||||
}
|
||||
|
||||
# Called when read gets Ctrl-D. On a terminal treat it like Enter, but if
|
||||
# input has really ended (closed pipe) exit, or the retry loop spins forever
|
||||
function end_of_input() {
|
||||
[[ -t 0 ]] || exit 1
|
||||
# Ctrl-D doesn't move to a new line like Enter, which the prompts expect
|
||||
echo -en "${NEWLINE}" >&2
|
||||
}
|
||||
|
||||
function render_keyboard() {
|
||||
declare pos=$(( BORDER*2+7 ))
|
||||
echo -en "${RESET}\e[$pos;0H"
|
||||
|
||||
Reference in new issue
Block a user