summaryrefslogtreecommitdiff
path: root/etc/functions
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-01-20 12:05:46 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-01-20 12:05:46 +0100
commit67c12df42e54167d6d5e0ed1218e8e381bfac80e (patch)
tree18d0b900492bd945ed75f1c793d69766f24bfed1 /etc/functions
parentee582e0961777c067966e8318659e4a2762ecea6 (diff)
Added confirm functions
Diffstat (limited to 'etc/functions')
-rw-r--r--etc/functions/confirm_no3
-rw-r--r--etc/functions/confirm_yes9
2 files changed, 12 insertions, 0 deletions
diff --git a/etc/functions/confirm_no b/etc/functions/confirm_no
new file mode 100644
index 0000000..c69b4c6
--- /dev/null
+++ b/etc/functions/confirm_no
@@ -0,0 +1,3 @@
+## vim:ft=zsh
+echo -n "$* [y/N] "
+read -q
diff --git a/etc/functions/confirm_yes b/etc/functions/confirm_yes
new file mode 100644
index 0000000..7389d1d
--- /dev/null
+++ b/etc/functions/confirm_yes
@@ -0,0 +1,9 @@
+## vim:ft=zsh
+echo -n "$* [Y/n] "
+read -k 1
+[[ $REPLY != $'\n' ]] && echo
+if [[ $REPLY == 'y' || $REPLY == 'Y' || $REPLY == $'\n' ]] {
+ true
+} else {
+ false
+}