[GRASS5] Re: [GRASS-CVS] glynn: grass51/general/g.parser main.c,2.0,2.1

Markus Neteler neteler at itc.it
Mon Dec 6 05:57:28 EST 2004


On Sun, Dec 05, 2004 at 04:22:04PM +1300, Hamish wrote:
> > > does the change below affect existing GRASS scripts?
> > 
> > > > -	sprintf(buff, "GIS_OPT_%s=%s", option->key, option->answer);
> > > > +	sprintf(buff, "GIS_OPT_%s=%s", option->key, option->answer ? option->answer : "");
> > 
> > The only way in which it could affect existing scripts is if they are
> > doing e.g.:
> > 
> > 	if [ $GIS_OPT_something = '(null)' ] ; then
> > 		...
> > 
> > which is probably a bug. I'm not sure that sprintf(buff, "%s", NULL)
> > is guaranteed to generate "(null)".
> > 
> > However, there is at least one script (i.image.mosaic) which expects a
> > missing argument to result in $GIS_OPT_* being the empty string.
> > 
> > N.B.: this is a fix for bug #2740.
> 
> 
> 
> grass57/scripts$ grep -r '(null)' * | cut -f1 -d/ | uniq
> d.monsize
> d.out.png
> d.rast.leg
> d.slide.show
> g.manual
> g.mlist
> g.mremove
> i.spectral
> r.out.gdal
> r.reclass.area
> r.shaded.relief
> v.in.garmin
> 
> 
> Is the above change permanent and should all these scripts change to 
> 
> - if [ $GIS_OPT_something = '(null)' ] ; then
> + if [ -z $GIS_OPT_something ] ; then
>    ...
> 
> 
> either way is ok, but we need to pick one way and stick with it.
> 
> 'db.connect -p' also shows (null) from a new mapset.
> 

I think that this has to be urgently resolved.
Glynn, please suggest a solution...

Markus




More information about the grass-dev mailing list