From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 80929139694 for ; Mon, 12 Jun 2017 23:01:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 48DFC21C039; Mon, 12 Jun 2017 23:01:50 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2624221C039 for ; Mon, 12 Jun 2017 23:01:50 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DD1B83419E6 for ; Mon, 12 Jun 2017 23:01:48 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 48AEF7480 for ; Mon, 12 Jun 2017 23:01:47 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1497308298.1e837d596e483ceb5cec177a6c7faff24a42384b.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: scripts/ X-VCS-Repository: proj/openrc X-VCS-Files: scripts/shutdown.in X-VCS-Directories: scripts/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 1e837d596e483ceb5cec177a6c7faff24a42384b X-VCS-Branch: master Date: Mon, 12 Jun 2017 23:01:47 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 42fce52a-332b-4be0-abe0-9e846f20adb0 X-Archives-Hash: dfe1a95da03311b9dca0cf4f2034256e commit: 1e837d596e483ceb5cec177a6c7faff24a42384b Author: William Hubbs gmail com> AuthorDate: Mon Jun 12 22:58:18 2017 +0000 Commit: William Hubbs gentoo 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} ${@}