summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-02-26 12:52:43 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-02-26 12:52:43 -0800
commitb3b95f5565d84cebe5fca613a81e2cf6f93c658e (patch)
tree1427c8b0dbc0cb2650043cb10b0d8f25b3daa17e /scripts
parent43ccc1bb5e446ec8c94cabe21fa7e8d68ffe07e3 (diff)
downloadvyatta-op-b3b95f5565d84cebe5fca613a81e2cf6f93c658e.tar.gz
vyatta-op-b3b95f5565d84cebe5fca613a81e2cf6f93c658e.zip
Add default option to yesno for shutdown
Make it work like reboot
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/yesno12
1 files changed, 12 insertions, 0 deletions
diff --git a/scripts/yesno b/scripts/yesno
index dd186c7..cbed0e0 100755
--- a/scripts/yesno
+++ b/scripts/yesno
@@ -1,14 +1,26 @@
#! /bin/bash
# Usage: yesno prompt...
+default=
+if [ $1 == "-y" ]
+then default='y'; shift
+fi
+
if [ $# -eq 0 ]
then prompt="yes or no: "
else prompt="$*"
fi
+if [ ! -z $default ]; then
+ prompt+="[y]"
+fi
+
while true
do
read -p "$prompt" || exit 1
+ if [ -z "$REPLY" -a ! -z $default ]
+ then REPLY=$default
+ fi
case "$REPLY" in
y*|Y*) exit 0;;
n*|n*) exit 1;;