|
@@ -744,6 +744,9 @@ def load_env():
|
|
|
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 @@ PROMPT_COMMAND=grass_prompt\n""" % (_("2D and 3D raster MASKs present"),
|
|
|
_("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')
|