diff options
author | Olav Vitters <olav@vitters.nl> | 2020-08-04 10:07:35 +0200 |
---|---|---|
committer | Olav Vitters <olav@vitters.nl> | 2020-08-04 10:07:35 +0200 |
commit | 40a4bd93aacafca2a6284c3bd493bcfa8eac7aef (patch) | |
tree | 68be3c5715c6eab20d861c1db4068d951a82b59f /etc | |
parent | faf3f57b14de38b264ef94becbbb4c8519970509 (diff) | |
download | initscripts-40a4bd93aacafca2a6284c3bd493bcfa8eac7aef.tar initscripts-40a4bd93aacafca2a6284c3bd493bcfa8eac7aef.tar.gz initscripts-40a4bd93aacafca2a6284c3bd493bcfa8eac7aef.tar.bz2 initscripts-40a4bd93aacafca2a6284c3bd493bcfa8eac7aef.tar.xz initscripts-40a4bd93aacafca2a6284c3bd493bcfa8eac7aef.zip |
etc/rc.d/init.d/functions: prevent gprintf from showing an "shift" error message
meanwhile, cleanup tabs and spaces
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/rc.d/init.d/functions | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/etc/rc.d/init.d/functions b/etc/rc.d/init.d/functions index 2ce76120..cc2f2c26 100755 --- a/etc/rc.d/init.d/functions +++ b/etc/rc.d/init.d/functions @@ -109,20 +109,20 @@ if [ -z "${BOOTUP:-}" ]; then fi gprintf() { - if [ -x /bin/gettext -a -n "$1" ]; then - if [ -n "$GP_LANG" ]; then - local TEXT=`LC_ALL=$GP_LANG LANGUAGE=$GP_LANGUAGE gettext -e --domain=$TEXTDOMAIN -- "$1"` - else - local TEXT=`gettext -e --domain=$TEXTDOMAIN -- "$1"` - fi - else - local TEXT=$1 - fi - [ "${1#*\\n}" ] || TEXT="$TEXT\n" - - shift - printf -- "$TEXT" "$@" -} + if [ -x /bin/gettext ] && [ -n "$1" ]; then + if [ -n "$GP_LANG" ]; then + local TEXT=$(LC_ALL=$GP_LANG LANGUAGE=$GP_LANGUAGE gettext -e --domain=$TEXTDOMAIN -- "$1") + else + local TEXT=$(gettext -e --domain=$TEXTDOMAIN -- "$1") + fi + else + local TEXT=$1 + fi + [ "${1#*\\n}" ] || TEXT="$TEXT\n" + + shift + printf -- "$TEXT" "$@" +} # Frontend to gprintf (support up to 4 %s in format string) # returns the message transleted in GPRINTF_MSG and @@ -130,24 +130,29 @@ gprintf() { # This simplifies a lot the call of functions like action, # now with i18n support gprintf_msg_rest() { -case "$1" in + GPRINTF_REST="" + return + fi + case "$1" in *%s*%s*%s*%s*) - GPRINTF_MSG=$(gprintf "$1" "$2" "$3" "$4" "$5") - shift 5;; + GPRINTF_MSG=$(gprintf "$1" "$2" "$3" "$4" "$5") + shift 5;; *%s*%s*%s*) - GPRINTF_MSG=$(gprintf "$1" "$2" "$3" "$4") - shift 4;; + GPRINTF_MSG=$(gprintf "$1" "$2" "$3" "$4") + shift 4;; *%s*%s*) - GPRINTF_MSG=$(gprintf "$1" "$2" "$3") - shift 3;; + GPRINTF_MSG=$(gprintf "$1" "$2" "$3") + shift 3;; *%s*) - GPRINTF_MSG=$(gprintf "$1" "$2") - shift 2;; + GPRINTF_MSG=$(gprintf "$1" "$2") + shift 2;; *) - GPRINTF_MSG=$(gprintf "$1") - shift;; -esac -GPRINTF_REST="$@" + GPRINTF_MSG=$(gprintf "$1") + # function may be called without any arguments, e.g. for 'success' + [ $# -ne 0 ] && shift + ;; + esac + GPRINTF_REST="$@" } # Check if $pid (could be plural) are running with |