From b4255008b158e76fe595ec7d3021121b9d2257dd Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 5 Aug 2014 15:37:32 +0200 Subject: shutdown: if no args print usage(). --- shutdown.sh | 10 ++++++++-- 1 file 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 -- cgit 1.4.1