use "echo STR|wc -c" rather than unportable "expr length STR"
authorLasse Collin <lasse.collin@tukaani.org>
Wed, 14 May 2008 16:50:53 +0000 (18:50 +0200)
committerJim Meyering <meyering@redhat.com>
Wed, 14 May 2008 16:50:53 +0000 (18:50 +0200)
* build-aux/mktempd (mktempd): Vendor-supplied expr from at least
OpenBSD 4.3 and Solaris 10 do not honor expr's "length" function.

ChangeLog
build-aux/mktempd

index 32e1a87..b3ef40b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-05-14  Lasse Collin  <lasse.collin@tukaani.org>
+
+       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.
+
 2008-05-14  Jim Meyering  <meyering@redhat.com>
 
        use dd ifs=$n count=1 ... rather than less-portable head -c$n
index 5bee3f0..2bb424f 100755 (executable)
@@ -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