summary refs log tree commit diff
diff options
context:
space:
mode:
authorJuan RP <xtraeme@gmail.com>2014-08-05 15:37:32 +0200
committerJuan RP <xtraeme@gmail.com>2014-08-05 15:37:32 +0200
commitb4255008b158e76fe595ec7d3021121b9d2257dd (patch)
treef06b03d2ae8808d7cb0311254e003458124b9dd7
parent4914505c4f9ddb16855c7738d3cf25ace191ee7d (diff)
downloadrunit-void-b4255008b158e76fe595ec7d3021121b9d2257dd.tar.gz
runit-void-b4255008b158e76fe595ec7d3021121b9d2257dd.tar.xz
runit-void-b4255008b158e76fe595ec7d3021121b9d2257dd.zip
shutdown: if no args print usage().
-rwxr-xr-xshutdown.sh10
1 files changed, 8 insertions, 2 deletions
diff --git a/shutdown.sh b/shutdown.sh
index 20fd707..0cf5c24 100755
--- a/shutdown.sh
+++ b/shutdown.sh
@@ -5,6 +5,10 @@ single() {
   runsvchdir single
 }
 
+usage() {
+  echo "Usage: shutdown [-fF] [-kchPr] time [warning message]" >/dev/stderr; exit 1
+}
+
 action=single
 
 while getopts akrhPHfFnct: opt; do
@@ -17,12 +21,14 @@ while getopts akrhPHfFnct: opt; do
     c) action=cancel;;
     h|P) action=halt;;
     r) action=reboot;;
-    [?]) echo "Usage: shutdown [-fF] [-kchPr] time [warning message]" >/dev/stderr; exit 1;;
+    [?]) usage;;
   esac
 done
 shift $(expr $OPTIND - 1)
 
-[ -n "$1" ] && time=$1 && shift
+[ $# -eq 0 ] && usage
+
+time=$1; shift
 message="${*:-system is going down}"
 
 if [ "$action" = "cancel" ]; then