fix argument parsing for the sysvinit shutdown wrapper

This fixes #140.
This commit is contained in:
William Hubbs 2017-06-12 17:58:18 -05:00
parent dcc686e42b
commit 1e837d596e

View File

@ -1,17 +1,21 @@
#!@SHELL@ #!@SHELL@
args= poweroff_arg=
for x; do while getopts :HhPr opt; do
case "$x" in case "$opt" in
-h) args=" ${args} --halt" ;; h|P) poweroff_arg=--poweroff ;;
*) args=" ${args} ${x} " ;; H) poweroff_arg=--halt ;;
r) poweroff_arg=--reboot ;;
\?) printf "${0##*/}: invalid option ${optarg}\n" >&2
exit 1
;;
esac esac
done done
shift $((OPTIND-1))
case "$args" in if [ -z "${poweroff_arg}" ]; then
*-h|--halt*) ;; poweroff_arg=--single
*-s|--single*) ;; fi
*) args=" --single ${args}" ;;
esac
exec @SBINDIR@/openrc-shutdown "$args" echo @SBINDIR@/openrc-shutdown ${poweroff_arg} ${@}
exec @SBINDIR@/openrc-shutdown ${poweroff_arg} ${@}