From 06a8584112a3f8baa7730c020155f7fa9c879f07 Mon Sep 17 00:00:00 2001 From: Mark Hindley Date: Fri, 25 Oct 2024 15:44:42 +0100 Subject: [PATCH] Optimise with suggestions by @navi with thanks. --- sh/openrc-run.sh.in | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sh/openrc-run.sh.in b/sh/openrc-run.sh.in index 5ecfae3b2..caf78f12e 100644 --- a/sh/openrc-run.sh.in +++ b/sh/openrc-run.sh.in @@ -41,18 +41,16 @@ sourcex() apply_ulimits() { - if [ $(( $# % 2 )) -eq 0 ]; then - while [ $# -gt 0 ] ; do - flag=$1 - val=$2 - shift 2 - if ! ulimit "${flag}" "${val}"; then - eerror "${RC_SVCNAME}: unable to apply RC_ULIMIT settings" - fi - done - else + if [ $(( $# % 2 )) -eq 1 ]; then eerror "${RC_SVCNAME}: Invalid RC_ULIMIT setting" + return 1 fi + while [ $# -gt 0 ] ; do + if ! ulimit "${1}" "${2}"; then + eerror "${RC_SVCNAME}: unable to apply RC_ULIMIT settings" + fi + shift 2 + done } sourcex "@LIBEXECDIR@/sh/functions.sh"