commit d94b6902530b6d2d35fe4b24c835b784a0f739af parent bdeae677b984208d26ac47a2e0a942a5358f6191 Author: Cem Keylan <cem@ckyln.com> Date: Thu, 5 Nov 2020 23:50:55 +0300 yesno(): add docstring, return 2 if any button other than y/n is received Diffstat:
M | bin/muw | | | 5 | ++++- |
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/bin/muw b/bin/muw @@ -30,10 +30,13 @@ getbut() { } yesno() { + # Function to ask the user yes/no questions. Returns 0 if the button + # received is Y/y, Returns 1 if the button received is N/n, and returns + # 2 if any other button is received. printf '%s\n' "$@"; printf 'y/n: ' ans=$(getbut) printf '%s\n' "$ans" >&2 - case "$ans" in [Yy]) return 0; esac; return 1 + case "$ans" in Y|y) return 0;; N|n) return 1; esac; return 2 } delete() {