[GRASS-SVN] r39326 - grass/branches/develbranch_6/lib/init

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 29 09:36:06 EDT 2009


Author: marisn
Date: 2009-09-29 09:36:06 -0400 (Tue, 29 Sep 2009)
New Revision: 39326

Modified:
   grass/branches/develbranch_6/lib/init/grass.src
Log:
Provide terminal if GRASS is started without it

Modified: grass/branches/develbranch_6/lib/init/grass.src
===================================================================
--- grass/branches/develbranch_6/lib/init/grass.src	2009-09-29 10:43:08 UTC (rev 39325)
+++ grass/branches/develbranch_6/lib/init/grass.src	2009-09-29 13:36:06 UTC (rev 39326)
@@ -22,4 +22,36 @@
 GISBASE="GISBASE_VALUE"
 export GISBASE
 
-exec "$GISBASE/etc/Init.sh" "$@"
+GISRCRC="$HOME/.grassrc6"
+
+if [ -n "$GRASS_BATCH_JOB" ] ; then
+	exec "$GISBASE/etc/Init.sh" "$@"
+fi
+
+if test -t 0; then
+	# We are running from some terminal (i.e. xterm).
+	exec "$GISBASE/etc/Init.sh" "$@"
+else
+	# We are running headless...
+	if [ ! -f "$GISRCRC" ] ; then
+		# First time user...
+		( exec xdg-terminal -e $0 "$@" ) &>/dev/null
+		# If there is no xdg-terminal, then fall back to xterm
+		( exec xterm -e $0 "$@" ) &>/dev/null
+	else
+		# Returning user may have preffered GRASS terminal application
+		GRASS_XTERM=`awk '/GRASS_XTERM/ {print $2}' "$GISRCRC"  2>/dev/null`
+		if [ -n "$GRASS_XTERM" ]; then
+			# User has preffered GRASS terminal app
+			( exec $GRASS_XTERM -e $0 "$@" ) &>/dev/null
+		else
+			# Starting user's preffered terminal app
+			( exec xdg-terminal -e $0 "$@" ) &>/dev/null
+			# If there is no xdg-terminal, then fall back to xterm
+			( exec xterm -e $0 "$@" ) &>/dev/null
+		fi;
+	fi;
+fi;
+
+exit 1; # If we got so far, it's an error.
+



More information about the grass-commit mailing list