[GRASS-dev] [grass.script.core] parser() casts options as strings

Glynn Clements glynn at gclements.plus.com
Fri Aug 7 15:14:15 EDT 2009

Hamish wrote:

> > In r38629, options are checked regardless of whether opt->options is
> > present.
> if someone does:
> g.module string_opt1= string_opt2=foo
> or string_opt1="" should it catch that as an error?

Not in the parser; an empty string is still a string.

> I know currently
> there are some module checks for that sort of thing (opt->answer pointer
> exists but points to an empty string), but if would be better to have the
> parser take care of that. are there cases where it might be valid?
> d.module text="" ??

It might be valid.

However: one problem with a module wanting to distinguish between an
option being omitted and it having the empty string as a value is
that, AFAICT, the GUI doesn't allow you to pass an empty string. If
you specify a value, it passes the option; if you leave the value
field blank, it doesn't pass the option.

For shell scripts, it might be convenient to allow passing an empty
string instead of omitting an option. It's much easier to pass an
option with a possibly-empty value than to conditionally pass an

> also, vaguely related: one thing I've never been clear on:
> what is the reason to use G_done_msg(" "); instead of G_done_msg(""); ?

No idea.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list