FW: Dynamically changing window size

Dan M. Schmitt dms0606 at tam2000.tamu.edu
Fri Dec 16 09:40:34 EST 1994


Conn Copas (cvc at itd.dsto.gov.au) wrote:
: Mike Foster writes:
: > 
: >      However, how can changes in the .grassrc file take effect WITHOUT
: > exiting and re-starting GRASS?  A simple Bourne shell script (inspired by
: > GIS.sh) as follows does NOT do the job UNLESS Zhian exits, then restarts
: > GRASS:
: > 
: > :
: > g.gisenv XDRIVER_HEIGHT=
: > g.gisenv XDRIVER_WIDTH=
: > export XDRIVER_HEIGHT
: > export XDRIVER_WIDTH
: > g.gisenv XDRIVER_HEIGHT=$1
: > g.gisenv XDRIVER_WIDTH=$2
: > export XDRIVER_HEIGHT
: > export XDRIVER_WIDTH
: > eval `g.gisenv`
: > 
: > 
: > What silly  thing have(n't) we done?
: > 
: If you change those values at the GRASS prompt and then export them to your
: environment, they do indeed take effect. However, if you try to change these
: values by calling a script, that shell cannot update the environment of its
: parent. You can issue the Unix 'env' command at your GRASS prompt to verify
: this.

: The relevant GRASS code for all this is
: 	/src/display/devices/XDRIVER/XDRIVER/Graph_Set.c
: It calls the function 'get_user' in order to grab these environment variables
: prior to creating a monitor. If you absolutely have to resize the monitor
: through a sub-shell, then it looks as if you will have to subvert this code
: somehow. 


If the problem is that the subshell does not set the environment
variables such that an 'env' will see them, the soulution is
to "source" the file rather than run it.
In bourn shell

	. NeatStuff.sh

rather than

	./NeatStuff.sh

In C shell

	source NeatStuff.csh

rather than

	./NeatStuff.csh

These operations execute the script in the current shell's process
space and do modifications (to things such as environment variables)
there.  (This should be the equivilant to changeing them at the grass
prompt with set/export/setenv commands)

Dan Schmitt
Systems Analyst                                 IEEE Member #3779402

Ranching Systems Group                          Phone # (409) 845-7333
Department of Rangeland Ecology and Management  Fax   # (409) 847-9366
Texas A&M University                            Home  # (409) 846-3914
College Station Texas 77843-2126                ICBM: 30.67 N, 96.37 W




More information about the grass-user mailing list