[PATCH v2 modular] build.sh: replace expr substr function with colon operator

Gaetan Nadon memsize at videotron.ca
Mon Jan 16 14:48:49 PST 2012


Not all "expr" implementations have a "substr" string argument.

  "According to the POSIX standard, the use of string arguments length,
   substr, index, or match produces undefined results."

http://www.freebsd.org/cgi/man.cgi?query=expr&apropos=0&sektion=0&manpath=
FreeBSD+9.0-RELEASE&arch=default&format=html

Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
---
 build.sh |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/build.sh b/build.sh
index b01d652..29bdd17 100755
--- a/build.sh
+++ b/build.sh
@@ -80,12 +80,14 @@ setup_buildenv() {
 
     # Support previous usage of LIBDIR which was a subdir relative to PREFIX
     # We use EPREFIX as this is what PREFIX really meant at the time
-    if [ X"`expr substr $LIBDIR 1 1`" != X/ ]; then
-	echo ""
-	echo "Warning: this usage of \$LIBDIR is deprecated. Use a full path name."
-	echo "The supplied value \"$LIBDIR\" has been replaced with $EPREFIX/$LIBDIR."
-	echo ""
-	    LIBDIR=$EPREFIX/$LIBDIR
+    if [ X"$LIBDIR" != X ]; then
+	if [ X"`expr $LIBDIR : "\(.\)"`" != X/ ]; then
+	    echo ""
+	    echo "Warning: this usage of \$LIBDIR is deprecated. Use a full path name."
+	    echo "The supplied value \"$LIBDIR\" has been replaced with $EPREFIX/$LIBDIR."
+	    echo ""
+		LIBDIR=$EPREFIX/$LIBDIR
+	fi
     fi
 
     # All directories variables must be full path names
@@ -1055,7 +1057,7 @@ usage() {
 check_full_path () {
     path=$1
     varname=$2
-    if [ X"`expr substr $path 1 1`" != X/ ]; then
+    if [ X"`expr $path : "\(.\)"`" != X/ ]; then
 	echo "The path \"$path\" supplied by \"$varname\" must be a full path name"
 	echo ""
 	usage
-- 
1.7.5.4



More information about the xorg-devel mailing list