commit:     e565ecb9cc44e7af96faf0f1b50c2a5a142dc7ca
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Jul  1 20:01:32 2022 +0000
Commit:     Joonas Niilola <juippis <AT> gentoo <DOT> org>
CommitDate: Sun Jul  3 06:06:43 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e565ecb9

media-video/mjpg-streamer: Avoid non-POSIX features in runscript

Use [ rather than [[ (SC3010). Don't use += (SC3024). Don't use string
replacing forms of parameter expansion (SC3060); instead use tr(1).

Closes: https://bugs.gentoo.org/848474
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>

 media-video/mjpg-streamer/files/mjpg-streamer.initd | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/media-video/mjpg-streamer/files/mjpg-streamer.initd 
b/media-video/mjpg-streamer/files/mjpg-streamer.initd
index e7116dba01d2..3b307e777c94 100644
--- a/media-video/mjpg-streamer/files/mjpg-streamer.initd
+++ b/media-video/mjpg-streamer/files/mjpg-streamer.initd
@@ -3,7 +3,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 MJPG_STREAMER_PIDFILE="${MJPG_STREAMER_PIDFILE:-/var/run/${SVCNAME}.pid}"
-MY_NAME=${SVCNAME//-/_}
+MY_NAME=$(printf %s "${SVCNAME}" | tr - _)
 
 depend() {
        use logger
@@ -11,17 +11,16 @@ depend() {
 }
 
 checkconfig() {
-       local vars
+       set --
 
-       [[ ${INPUT_PLUGIN} ]] || vars+=\ INPUT_PLUGIN
-       [[ ${OUTPUT_PLUGIN} ]] || vars+=\ OUTPUT_PLUGIN
-       [[ ${MJPG_STREAMER_USER} ]] || vars+=\ MJPG_STREAMER_USER
-       [[ ${MJPG_STREAMER_GROUP} ]] || vars+=\ MJPG_STREAMER_GROUP
-       vars="${vars# }"
+       [ "${INPUT_PLUGIN}" ] || set -- "$@" INPUT_PLUGIN
+       [ "${OUTPUT_PLUGIN}" ] || set -- "$@" OUTPUT_PLUGIN
+       [ "${MJPG_STREAMER_USER}" ] || set -- "$@" MJPG_STREAMER_USER
+       [ "${MJPG_STREAMER_GROUP}" ] || set -- "$@" MJPG_STREAMER_GROUP
 
-       if [[ ${vars} ]]; then
+       if [ $# -gt 0 ]; then
                eerror "Required variables in /etc/conf.d/${SVCNAME} are not 
set:"
-               eerror "  ${vars// /, }"
+               eerror " $(IFS=,; printf %s "$*")"
                return 1
        fi
 
@@ -31,7 +30,7 @@ checkconfig() {
 start() {
        checkconfig || return $?
        ebegin "Starting ${SVCNAME}"
-       start-stop-daemon --start --exec /usr/bin/${MY_NAME} \
+       start-stop-daemon --start --exec "/usr/bin/${MY_NAME}" \
                --user "${MJPG_STREAMER_USER}" \
                --group "${MJPG_STREAMER_GROUP}" -w 100 -b -m \
                --pidfile "${MJPG_STREAMER_PIDFILE}" \
@@ -42,7 +41,7 @@ start() {
 
 stop() {
        ebegin "Stopping ${SVCNAME}"
-       start-stop-daemon --stop --exec /usr/bin/${MY_NAME} \
+       start-stop-daemon --stop --exec "/usr/bin/${MY_NAME}" \
                --pidfile "${MJPG_STREAMER_PIDFILE}"
        eend $?
 }

Reply via email to