#2679: Drop or fix setting of Location and Mapset using environmental variables
-------------------------------------------------+-------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.1.0
Component: Startup | Version: svn-trunk
Keywords: init, grass.py, interface, CLI, | CPU: Unspecified
script, batch job |
Platform: Unspecified |
-------------------------------------------------+-------------------------
The [source:grass/trunk/lib/init/grass7.html#L291 manual describes] that
one can set Location and Mapset using system environmental variables but
it does not work:
{{{
$ export GISDBASE=~/grassdata/
$ export LOCATION_NAME=nc_spm_08_grass7_tests_2
$ export MAPSET=landsat
$ .../grass71 -
Cleaning up temporary files...
Starting GRASS GIS...
Traceback (most recent call last):
File ".../grass71", line 1423, in <module>
non_interactive(args[0])
File ".../grass71", line 586, in non_interactive
if gisdbase and location_name and mapset:
NameError: global name 'gisdbase' is not defined
}}}
I was wondering if I broke it but I get this behavior in r65235 before any
changes I made. It actually seems that is was always broken since r37863,
translating from Bash to Python.
This means that nobody is using with 7 it because nobody complains. For
now I just [source:grass/trunk/lib/init/grass.py#L783 put] `pass` in to
that `if` branch (it will fail later).
Also the dash used in this context seems quite strange, especially for
GRASS. We should consider alternatives.
In general this behavior seems useless to me, why use environmental
variable when I can use parameter? However, it might become quite useful
with the "exec subcommand" (#2579) for running commands inside the
session. You would set the environment and then just call grass:
{{{
export GISDBASE=~/grassdata/
export LOCATION_NAME=nc_spm_08_grass7_tests_2
export MAPSET=landsat
grass7 - exec g.region -p
}}}
Do we want to restore this behavior or it is ok to drop it?
If we want to fix also 7.0, some copy & paste should be possible.
PS: Either way, I won't be able to work on it right now, so if somebody
can take over, it would be great. (It should be much easier now after the
refactoring. There are notes in the source code about what needs to be
done.)
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2679>
GRASS GIS <http://grass.osgeo.org>