public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "William Hubbs" <williamh@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/openrc:master commit in: scripts/
Date: Mon, 12 Jun 2017 23:01:47 +0000 (UTC)	[thread overview]
Message-ID: <1497308298.1e837d596e483ceb5cec177a6c7faff24a42384b.williamh@OpenRC> (raw)

commit:     1e837d596e483ceb5cec177a6c7faff24a42384b
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Jun 12 22:58:18 2017 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jun 12 22:58:18 2017 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=1e837d59

fix argument parsing for the sysvinit shutdown wrapper

This fixes #140.

 scripts/shutdown.in | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

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


             reply	other threads:[~2017-06-12 23:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-12 23:01 William Hubbs [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-07-11 19:57 [gentoo-commits] proj/openrc:master commit in: scripts/ William Hubbs
2017-07-11 17:06 William Hubbs
2017-07-11 16:14 William Hubbs
2017-07-10 23:37 William Hubbs
2017-06-12 23:01 William Hubbs
2017-06-12 23:01 William Hubbs
2017-06-12 15:41 William Hubbs
2017-06-12 15:41 William Hubbs
2017-06-07 16:34 William Hubbs
2017-02-22 20:53 William Hubbs
2017-01-26 21:40 William Hubbs
2017-01-09  2:43 William Hubbs
2011-11-17 18:28 William Hubbs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1497308298.1e837d596e483ceb5cec177a6c7faff24a42384b.williamh@OpenRC \
    --to=williamh@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox