From 3fca553dae761595885fff8dd1d5491979e9c585 Mon Sep 17 00:00:00 2001 From: kevin zhuang Date: Sat, 11 Apr 2020 15:32:37 +1000 Subject: [PATCH] added confirmation helper --- helper/get_confirmation | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 helper/get_confirmation diff --git a/helper/get_confirmation b/helper/get_confirmation new file mode 100644 index 0000000..952bbe2 --- /dev/null +++ b/helper/get_confirmation @@ -0,0 +1,16 @@ +#!/bin/bash +# +# confirmaiton helper +# +# @params +# Globals +# ${confirm}: y/n the result of the confirmation +# Arguments +# $1: message to show + +function get_confirmation() { + unset confirm + while [[ "${confirm}" != 'y' && "${confirm}" != 'n' ]]; do + read -p "$1(y/n): " confirm + done +}