Skip to content

Commit

Permalink
Optimise with suggestions by @navi with thanks.
Browse files Browse the repository at this point in the history
  • Loading branch information
markhindley committed Oct 25, 2024
1 parent 204f16a commit 06a8584
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions sh/openrc-run.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 06a8584

Please sign in to comment.