]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
Use buggy awk-printf wrapper only if /bin/printf is not available.
authorElan Ruusamäe <glen@pld-linux.org>
Sun, 17 Sep 2006 15:01:47 +0000 (15:01 +0000)
committerElan Ruusamäe <glen@pld-linux.org>
Sun, 17 Sep 2006 15:01:47 +0000 (15:01 +0000)
svn-id: @7764

rc.d/init.d/functions

index 8c94166e9b17a208ad4e30508fc05d64c1db1035..dfc747a72ceadc556596d7def9a2c486203612ec 100644 (file)
@@ -200,22 +200,25 @@ termput()
        fi
 }
 
-# printf equivalent
-printf_()
-{
-       typeset text m
-       text="$1" ;
-       shift ;
-       if [ $# -gt 0 ]; then
-               m="$1";
-               shift;
-               while [ $# -gt 0 ]; do
-                       m="$m\",\"$1" ;
-                       shift ;
-               done
-       fi
-       awk "BEGIN {printf \"$text\", \"$m\"; }"
-}
+if [ ! -x /bin/printf ]; then
+       # printf equivalent
+       # FIXME: buggy when single or double quotes in message!
+       printf()
+       {
+               typeset text m
+               text="$1"
+               shift
+               if [ $# -gt 0 ]; then
+                       m="$1"
+                       shift
+                       while [ $# -gt 0 ]; do
+                               m="$m\",\"$1"
+                               shift
+                       done
+               fi
+               awk "BEGIN {printf \"$text\", \"$m\"; }"
+       }
+fi
 
 # National language support function
 nls()
@@ -251,9 +254,9 @@ nls()
                printf "$message" "$@"
        elif [ -x /bin/gettext -o -x /usr/bin/gettext ]; then
                text=$(TEXTDOMAINDIR="/etc/sysconfig/locale" gettext -e --domain="${NLS_DOMAIN:-rc-scripts}" "$message")
-               printf_ "$text" "$@"
+               printf "$text" "$@"
        else
-               printf_ "$message" "$@"
+               printf "$message" "$@"
        fi
 
        echo -en "$msg_echo"
This page took 0.056489 seconds and 4 git commands to generate.