bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

two portability patches for build-aux/mktempd


From: Jim Meyering
Subject: two portability patches for build-aux/mktempd
Date: Wed, 14 May 2008 19:01:39 +0200

FYI, I've pushed these two changes:

2008-05-14  Jim Meyering  <address@hidden>

        use dd ifs=$n count=1 ... rather than less-portable head -c$n
        * build-aux/mktempd (rand_bytes): head's -cN option is not accepted
        by Solaris 10's /bin/head or by the one from HP-UX 11.x.
        Reported in http://sourceforge.net/forum/message.php?msg_id=4960334
        via Collin Lasse.

diff --git a/build-aux/mktempd b/build-aux/mktempd
index 7ac914b..5bee3f0 100755
--- a/build-aux/mktempd
+++ b/build-aux/mktempd
@@ -44,7 +44,7 @@ rand_bytes()
   dev_rand=/dev/urandom
   if test -r "$dev_rand"; then
     # Note: 256-length($chars) == 194; 3 copies of $chars is 186 + 8 = 194.
-    head -c$n "$dev_rand" | tr -c $chars 01234567$chars$chars$chars
+    dd ibs=$n count=1 if="$dev_rand" | tr -c $chars 01234567$chars$chars$chars
     return
   fi

=======================================================================
2008-05-14  Lasse Collin  <address@hidden>

        use "echo STR|wc -c" rather than unportable "expr length STR"
        * build-aux/mktempd (mktempd): Vendor-supplied expr from at least
        OpenBSD 4.3 and Solaris 10 do not honor expr's "length" function.


diff --git a/build-aux/mktempd b/build-aux/mktempd
index 5bee3f0..2bb424f 100755
--- a/build-aux/mktempd
+++ b/build-aux/mktempd
@@ -114,7 +114,9 @@ mktempd()
   base_template=`echo "$template"|sed 's/XX*$//'`

   # Calculate how many X's we've just removed.
-  nx=`expr length "$template" - length "$base_template"`
+  template_length=`echo "$template" | wc -c`
+  nx=`echo "$base_template" | wc -c`
+  nx=`expr $template_length - $nx`

   err=
   i=1
--
1.5.5.1.216.g33c73




reply via email to

[Prev in Thread] Current Thread [Next in Thread]