[GRASS-SVN] r61051 - grass/trunk/lib/init
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jun 29 03:22:23 PDT 2014
Author: martinl
Date: 2014-06-29 03:22:23 -0700 (Sun, 29 Jun 2014)
New Revision: 61051
Modified:
grass/trunk/lib/init/grass.py
Log:
grass.py: do not override already set GRASS environmental variables
Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py 2014-06-29 10:07:13 UTC (rev 61050)
+++ grass/trunk/lib/init/grass.py 2014-06-29 10:22:23 UTC (rev 61051)
@@ -746,7 +746,17 @@
k, v = map(lambda x: x.strip(), line.strip().split(' ', 1)[1].split('=', 1))
except:
continue
- os.environ[k] = v
+
+ evalue = os.getenv(k)
+ if evalue:
+ if k == 'GRASS_ADDON_PATH':
+ os.environ[k] = evalue + os.pathsep + v
+ else:
+ warning(_("Environmental variable '%s' already set, ignoring value '%s'") % \
+ (k, v))
+ else:
+ os.environ[k] = v
+
# Allow for mixed ISIS-GRASS Environment
if os.getenv('ISISROOT'):
isis = os.getenv('ISISROOT')
@@ -1131,8 +1141,14 @@
path = os.path.join(userhome, ".grass.bashrc") # left for backward compatibility
if os.access(path, os.R_OK):
f.write(readfile(path) + '\n')
- if os.access(grass_env_file, os.R_OK):
- f.write(readfile(grass_env_file) + '\n')
+ 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))
+ # if os.access(grass_env_file, os.R_OK):
+ # f.write(readfile(grass_env_file) + '\n')
f.write("export PATH=\"%s\"\n" % os.getenv('PATH'))
f.write("export HOME=\"%s\"\n" % userhome) # restore user home path
More information about the grass-commit
mailing list