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 32e1a871922cec36ed628e9191bb93e753748d5d..b3ef40bd9c3d712ebbed32440761b8bf5eb034d4 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 5bee3f0c76d4125130e0051d61998f9caa817970..2bb424f69efd583369ad674ce89b3944f8c19953 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