summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2014-06-02 22:07:30 (EDT)
committer P. J. McDermott <pj@pehjota.net>2014-06-02 22:07:30 (EDT)
commit341404a5f3ca4c5743fd619099d8627572d30099 (patch)
tree29273bd4022216ff97b0b6680ce46a4538d98d78
parentcc8a81cbfb50ff8a8367d77ef80bece937b6cbaf (diff)
/etc/rc.common: Simplify command lists a bit.
-rw-r--r--src.etc/rc.common16
1 files changed, 7 insertions, 9 deletions
diff --git a/src.etc/rc.common b/src.etc/rc.common
index 344e3e7..e495e1c 100644
--- a/src.etc/rc.common
+++ b/src.etc/rc.common
@@ -11,21 +11,22 @@
set -u
SCRIPT=''
+ALL_CMDS=''
LOG_MSG=''
EXTRA_COMMANDS=''
main()
{
local action="${2}"
- local all_cmds=
local es=
SCRIPT="${1}"
. "${SCRIPT}"
- all_cmds=" start stop restart ${EXTRA_COMMANDS} "
- if [ "x${all_cmds#* ${action} }" != "x${all_cmds}" ]; then
+ ALL_CMDS=" start stop restart ${EXTRA_COMMANDS} "
+
+ if [ "x${ALL_CMDS#* ${action} }" != "x${ALL_CMDS}" ]; then
${action}
es=${?}
log_end ${es}
@@ -42,13 +43,10 @@ tty_printf()
}
usage() {
- local cmd=
+ local cmds=
- tty_printf 'Usage: %s {start|stop|restart' "${SCRIPT}"
- if [ "x${EXTRA_COMMANDS:+set}" = 'xset' ]; then
- tty_printf '|%s' ${EXTRA_COMMANDS}
- fi
- tty_printf '}\n'
+ cmds="$(printf '%s|' ${ALL_CMDS})"
+ tty_printf 'Usage: %s {%s}\n' "${SCRIPT}" "${cmds%|}"
}
log()