[csw-devel] SF.net SVN: gar:[7838] csw/mgar/gar/v2-checkpkg/bin/checkpkg

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Jan 3 02:08:34 CET 2010


Revision: 7838
          http://gar.svn.sourceforge.net/gar/?rev=7838&view=rev
Author:   wahwah
Date:     2010-01-03 01:08:33 +0000 (Sun, 03 Jan 2010)

Log Message:
-----------
mGAR v2-checkpkg: Colors only in terminals

Modified Paths:
--------------
    csw/mgar/gar/v2-checkpkg/bin/checkpkg

Modified: csw/mgar/gar/v2-checkpkg/bin/checkpkg
===================================================================
--- csw/mgar/gar/v2-checkpkg/bin/checkpkg	2010-01-02 23:51:10 UTC (rev 7837)
+++ csw/mgar/gar/v2-checkpkg/bin/checkpkg	2010-01-03 01:08:33 UTC (rev 7838)
@@ -31,6 +31,17 @@
   readonly CHECKPKG_TMPDIR
 fi
 
+# Colors only when running interactively
+if [[ -t 1 ]]; then
+	GREEN="\\033[0;32;40m"
+	RED="\\033[1;31;40m"
+	COLOR_RESET="\\033[00m"
+else
+	GREEN=""
+	RED=""
+	COLOR_RESET=""
+fi
+
 # always print out a warning message. (to stderr)
 # exit script, if quit_on_warn set
 
@@ -555,10 +566,10 @@
 			printf "TEST: ${plugin} running..."
 			${plugin} $extra_options -e "${EXTRACTDIR}" ${pkgnames} > "${plugin_log}" 2>&1
 			if [[ "$?" -ne 0 ]]; then
-				printf "\rTEST: ${plugin} \\033[1;31;40m[FAIL]\\033[00m        \\n"
+				printf "\rTEST: ${plugin} ${RED}[FAIL]${COLOR_RESET}        \\n"
 				test_suite_ok=0
 			else
-				printf "\rTEST: ${plugin} \\033[0;32;40m[OK]\\033[00m        \\n"
+				printf "\rTEST: ${plugin} ${GREEN}[OK]${COLOR_RESET}        \\n"
 			fi
 		else
 			debugmsg "'${plugin}' is not executable"


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list