[GRASS-dev] Re: [GRASS5] [bug #4331] (grass) delete if file exist - flag

Glynn Clements glynn at gclements.plus.com
Sun May 7 03:17:28 EDT 2006


Cedric Shock wrote:

> > This (documentation) should be implemented into the parser.
> > A way could be to check if a module used
> >
> > cd ~/grass61/lib/gis > grep OUTPUT parser.c
> >         case G_OPT_R_OUTPUT:
> >         case G_OPT_V_OUTPUT:
> 
> A simpler and more accurate way would be to check, in parser.c, if any of the 
> options use a gisprompt of new,*. But this option really only works for c 
> modules. The check_overwrite routine in parser.c will probably reject the map 
> name again in modules called from a script that was passed the --o flag.
> 
> Scripts probably won't notice this nor pass it to modules that the script 
> calls. I'm not sure if there's even a method for passing this back to the 
> script from g.parser. There is a grass environment variable OVERWRITE that 
> parser.c checks as well as the --o flag, but I don't think it's set for 
> scripts run by g.parser. Should it be for consistency (seems dangerous)?

g.parser doesn't pass parser options back to the script, only the
flags and options defined with G_define_{flag,option}.

I would have thought that it would be sufficient for G_parser() to set
OVERWRITE itself if --o was used. That would then be inherited by the
script and by any modules which it calls.

> Perhaps it would be possible for parser.c to tell the difference between a 
> call from g.parser and a call from other modules to produce this help output 
> only for c grass modules that use new,*.

If that's needed, add a function to parser.c to enable the feature,
and change g.parser to call it. That's more robust than trying to
autodetect g.parser.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list