[GRASS5] [bug #1797] (grass) g.gisenv

Glynn Clements glynn.clements at virgin.net
Sat Apr 12 05:58:42 EDT 2003


Request Tracker wrote:

> Subject: g.gisenv
> 
> g.gisenv lets you set a variable to nonexistant values without a check, and
> the only way to go on is to exit GRASS and delete/edit the .grassrc5 file.
> 
> e.g., (user1 exists, usr1 doesn't)
> 
> GRASS:~ > g.gisenv MAPSET
> user1
> GRASS:~ > g.gisenv set="MAPSET=usr1"
> GRASS:~ >
> GRASS:~ > g.gisenv
> ERROR: MAPSET usr1 not found
> GRASS:~ >
> GRASS:~ > g.gisenv set="MAPSET=user1"
> ERROR: MAPSET usr1 not found
> GRASS:~ > exit
> 
> 
> I had a try using G_getenv to make a backup copy of the old value before
> attempting to G_setenv, and then test G_getenv for success, but as G_getenv
> fails with an exit, I can't set it back to the original if it fails..
> 
> When you try to fix it later with another set= to a real value, it fails (and
> G_fatal_error's) again before it can set the new value.
> 
> any ideas?

g.gisenv calls G_gisinit(), which generates a fatal error if the
mapset directory doesn't exist or has incorrect permissions (i.e. 
ownership).

Using:

	G_set_program_name(argv[0]);
	G_no_gisinit();

should work.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list