Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] Fun!



From: Øystein Walle <ow@xxxxxxxxxxxxxx>

---
 SW/source/installdeps.sh | 56 ++++++++++++++++++++++++++++++++----------------
 1 file changed, 38 insertions(+), 18 deletions(-)

diff --git a/SW/source/installdeps.sh b/SW/source/installdeps.sh
index 059ff3c..5a6dece 100755
--- a/SW/source/installdeps.sh
+++ b/SW/source/installdeps.sh
@@ -9,6 +9,26 @@ QCHARTSDIR=$BUILDDIR/include/qtcharts
 depsdir=$PWD/deps
 topdir=$PWD
 
+# Define colors if stdout is a terminal
+if [ -t 1 ]; then
+	# green=$(tput setaf 2)
+	# red=$(tput setaf 1)
+	# reset=$(tput sgr0)
+	red=''
+	green=''
+	reset='(B'
+else
+	red= green= reset=
+fi
+
+printok() {
+	printf "$green[OK]$reset %s\n" "$1"
+}
+
+printerr() {
+	printf "$red[ERROR]$reset %s\n" "$1" >&2
+}
+
 # compiling with mingw will yield 'Msys', while linux distros will yield 'GNU/Linux'
 DETECTED_OS=$(uname -o)
 
@@ -33,9 +53,9 @@ if [ ! -d "$BUILDDIR" ]; then
 	mkdir $BUILDDIR/bin
 	mkdir $BUILDDIR/lib
 	mkdir $BUILDDIR/html
-	echo "[OK]"
+	printok
 else
-	echo "[OK] Build Directory Found"
+	printok "Build Directory Found"
 fi
 echo ""
 
@@ -58,9 +78,9 @@ if [ ! -d "$GTESTDIR" ]; then
 	cp gtest.a $BUILDDIR/lib
 	cp -r ./../include $BUILDDIR
 	cd $topdir
-	echo "[OK]"
+	printok
 else
-	echo "[OK] Google Test Found"
+	printok "Google Test Found"
 fi
 echo ""
 
@@ -87,9 +107,9 @@ if [ ! -d "$QCHARTSDIR" ]; then
 	qmake CONFIG+="debug_and_release build_all nomake_demos_examples"; $MAKE -j1; $SUDO $MAKE install
 	mkdir $BUILDDIR/include/qtcharts
 	cd $topdir
-	echo "[OK]"
+	printok
 else
-	echo "[OK] QtCharts Found"
+	printok "QtCharts Found"
 fi
 echo ""
 
@@ -115,9 +135,9 @@ if [ ! -d "$ZLIBDIR" ]; then
 	cp zconf.h $BUILDDIR/include/zlib
 	cp libz.a $BUILDDIR/lib
 	cd $topdir
-	echo "[OK]"
+	printok
 else
-	echo "[OK] Zlib Found" 
+	printok "Zlib Found"
 fi
 echo ""
 
@@ -145,9 +165,9 @@ if [ ! -d "$PROTODIR" ]; then
 	then exit 1
 	fi
 	cd $topdir
-	echo "[OK]"
+	printok
 else
-	echo "[OK] Protobuf Found" 
+	printok "Protobuf Found"
 fi
 echo ""
 
@@ -164,9 +184,9 @@ if [ ! -d "$EIGENDIR" ]; then
 	mkdir $BUILDDIR/include/eigen
 	cp -r . $BUILDDIR/include/eigen
 	cd $topdir
-	echo "[OK]"
+	printok
 else
-	echo "[OK] Eigen FFT Found"
+	printok "Eigen FFT Found"
 fi
 echo ""
 
@@ -192,12 +212,12 @@ if [ "$DETECTED_OS" =  "Msys" ]; then
     if [ ! -f $BUILDDIR/release/Compress2003 ]; then
         cp $topdir/libs/compresslib/Compress2003.dll $BUILDDIR/release
     fi
-    echo "[OK] - installed/verified compressions libs for $DETECTED_OS"
+    printok "installed/verified compressions libs for $DETECTED_OS"
     echo ""
 elif [ "$DETECTED_OS" = "GNU/Linux" ]; then
-    echo "[OK] - no compression libs neccessary for $DETECTED_OS"
+    printok "no compression libs neccessary for $DETECTED_OS"
 else
-    echo "[ERROR] - failed installing compression libs, OS: $DETECTED_OS not recognized"
+    printerr "failed installing compression libs, OS: $DETECTED_OS not recognized"
 fi
 
 echo "Verifying SQL libraries Available"
@@ -212,7 +232,7 @@ if [ "$DETECTED_OS" =  "Msys" ]; then
     if [ ! -f $BUILDDIR/release/sqldrivers/qsqloci.dll ]; then
         cp $topdir/libs/sqldrivers/qsqloci.dll $BUILDDIR/release/sqldrivers/
     fi	
-    echo "[OK] - installed SQL drivers for $DETECTED_OS"
+    printok "installed SQL drivers for $DETECTED_OS"
 elif [ "$DETECTED_OS" = "GNU/Linux" ]; then
     if [ ! -f $BUILDDIR/debug/sqldrivers/libqsqloci.so ]; then
         cp $topdir/libs/sqldrivers/libqsqloci.so $BUILDDIR/debug/sqldrivers/
@@ -220,7 +240,7 @@ elif [ "$DETECTED_OS" = "GNU/Linux" ]; then
     if [ ! -f $BUILDDIR/release/sqldrivers/libqsqloci.so ]; then
         cp $topdir/libs/sqldrivers/libqsqloci.so $BUILDDIR/release/sqldrivers/
     fi
-    echo "[OK] - installed/verified SQL drivers for $DETECTED_OS"
+    printok "installed/verified SQL drivers for $DETECTED_OS"
 else
-    echo "[ERROR] - failed installing SQL drivers, OS: $DETECTED_OS not recognized"
+    printerr "failed installing SQL drivers, OS: $DETECTED_OS not recognized"
 fi
-- 
2.0.1



Messages sorted by: Reverse Date, Date, Thread, Author