[Olsr-dev] should bash be required?

John Hay (spam-protected)
Fri Sep 7 08:16:35 CEST 2007


Hi,

Would it be ok to try and get rid of bashisms? Not all unix machines
have bash installed. Here is my try at it. It was tested on FreeBSD
only, but I have tried to stay within the posix specs, so it should
work everywhere... I think. :-)

John
-- 
John Hay -- (spam-protected) / (spam-protected)


--- Makefile.inc.orig	2007-08-02 14:31:38.000000000 +0200
+++ Makefile.inc	2007-08-15 11:49:51.000000000 +0200
@@ -1,5 +1,5 @@
 # programs
-CCACHE ?=       $(shell bash -c "type -path ccache")
+CCACHE ?=       $(shell sh -c "which ccache")
 ifeq ($(origin CC),default)
 CC = 		$(CCACHE) gcc
 else


--- gcc-warnings.orig	2007-06-27 22:20:57.000000000 +0200
+++ gcc-warnings	2007-08-15 11:47:24.000000000 +0200
@@ -1,4 +1,4 @@
-#!/bin/bash --norc
+#!/bin/sh
 #
 # We expect warning options for gcc as argumenst and return the ones which are accepted
 # by the given gcc.
@@ -16,17 +16,29 @@
     esac
 done
 
-while read error; do 
-    case "$error" in
-    *error:\ unrecognized\ option*) opt="${error#*\`}"
-                                    opt="${opt%\'*}"
-                                    OPTS="${OPTS//$opt/}"
-                                    ;;
-    esac
-done < <($CC $OPTS -E - 2>&1 >/dev/null <<EOF
-    int main(void) {
-        return 0;
-    }
-    EOF)
-echo $OPTS
+testcompile() {
+    $CC $OPTS -E - 2>&1 <<- EOF
+	int main(void) {
+	    return 0;
+	}
+	EOF
+}
+
+parsetest() {
+    while read error; do 
+	case "$error" in
+	*error:\ unrecognized\ *option*)
+					opt="${error#*\`}"
+					opt="${opt%\'*}"
+					opt="${error#*\"}"
+					opt="${opt%\"*}"
+					OPTS=`echo $OPTS | sed -e s/$opt//g`
+					;;
+	esac
+    done
+    echo $OPTS
+}
+
+testcompile | parsetest
+
 exit 0




More information about the Olsr-dev mailing list