[GRASS-SVN] r61216 - grass/trunk/lib/init

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 9 05:08:31 PDT 2014


Author: martinl
Date: 2014-07-09 05:08:31 -0700 (Wed, 09 Jul 2014)
New Revision: 61216

Modified:
   grass/trunk/lib/init/grass.py
Log:
fix grass.py to accept custom PS1 and aliases (bashrc)

Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py	2014-07-09 11:05:55 UTC (rev 61215)
+++ grass/trunk/lib/init/grass.py	2014-07-09 12:08:31 UTC (rev 61216)
@@ -744,6 +744,9 @@
         return
 
     for line in readfile(grass_env_file).split(os.linesep):
+        if not line.lower().startswith('export'):
+            continue
+        
         try:
             k, v = map(lambda x: x.strip(), line.strip().split(' ', 1)[1].split('=', 1))
         except:
@@ -1139,16 +1142,27 @@
                                     _("Raster MASK present"),
                                     _("3D raster MASK present")))
 
-    # read environmental variables
-    path = os.path.join(userhome, ".grass.bashrc") # left for backward compatibility
+    # read environmental variables from GRASS 6 (left for backward
+    # compatibility)
+    path = os.path.join(userhome, ".grass.bashrc")
     if os.access(path, os.R_OK):
         f.write(readfile(path) + '\n')
+    
+    # write GRASS environmental variables to $LOCATION/.bashrc
     for env in os.environ.keys():
         if env.startswith('GRASS'):
             val = os.environ[env]
             if ' ' in val:
                 val = '"%s"' % val
             f.write('export %s=%s\n' % (env, val))
+    
+    # write aliases and custom settings from grass_env_file to
+    # $LOCATION/.bashrc
+    if os.access(grass_env_file, os.R_OK):
+        for line in readfile(grass_env_file).split(os.linesep):
+            if line.lower().startswith('export'):
+                continue
+            f.write(line + '\n')
     ### Replaced by code above (do not override already set up environment variables)
     ###    if os.access(grass_env_file, os.R_OK):
     ###        f.write(readfile(grass_env_file) + '\n')



More information about the grass-commit mailing list