From: Steven Baltakatei Sandoval Date: Sun, 28 Jun 2020 17:44:43 +0000 (+0000) Subject: feat(bktemp):Add promptLoop template X-Git-Tag: 0.1.0~7 X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/f6fd6da73dc386d6d8a8b6405c6c3c6c9d8f528f?hp=9367c58ecda7c9a9ac4f6a02103ffa28c81127ec feat(bktemp):Add promptLoop template Add template that prompts a user for input until a valid answer is provided. --- diff --git a/unitproc/bktemp-promptLoop b/unitproc/bktemp-promptLoop new file mode 100644 index 0000000..b476439 --- /dev/null +++ b/unitproc/bktemp-promptLoop @@ -0,0 +1,22 @@ +#!/bin/bash + +# Desc: Prompts user until valid answer given. + +while ! [ "$prompt_status" = "answered" ]; do + echo "Perform action? (y/n):" 1>&2; + read prompt; + case "$prompt" in + "y" | "yes") + echo -e "Doing stuff."; + prompt_status="answered"; + ;; + "n" | "no") + echo "Doing nothing."; + prompt_status="answered"; + ;; + *) + echo "WARNING:Invalid option $prompt" + prompt_status=""; + ;; + esac +done