> > CMD="v.build map=${VECT}@${MAPSET}"
> > - g.message "$CMD"
> > + g.message message="$CMD"
> > $CMD
> > done
MNeteler:
> ... is this a needed change?
...
> Most are without this parameter...
Needed in this case because the string contains a '=', which
confuses the parser.
That should really be fixed in the parser. Even in 6.x, an option name
cannot contain a space.
In 6.x, the test for whether an argument is an option finds the first
'=' in the string and checks that the immediately preceding character
is alphanumeric.
if (!p)
return 0;
if (p == string)
return 0;
p--;
if (!strchr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", *p))
return 0;
return 1;
}
In 7.0, the test uses strspn() to find the length of the prefix
consisting entirely of (lower-case) alphanumeric characters and
underscores, then checks that the following character is an '=' and
that the prefix doesn't begin or end with an underscore:
static int is_option(const char *string)
{
int n = strspn(string, "abcdefghijklmnopqrstuvwxyz0123456789_");
It would be simple to back-port the 7.0 version to 6.x. Compatibility
requires adding the upper-case characters, which are allowed in option
names in 6.x (e.g. r.terraflow's STREAM_DIR= option). Technically, the
check for a leading underscore should be removed, but I'm not sure
that actually matters.
> > > > CMD="v.build map=${VECT}@${MAPSET}"
> > > > - g.message "$CMD"
> > > > + g.message message="$CMD"
Hamish:
> > Needed in this case because the string contains a '=',
> > which confuses the parser.
Glynn:
> That should really be fixed in the parser. Even in 6.x, an
> option name cannot contain a space.
it's more general than that, e.g. this would need the option=
to be specified:
g.message message="minimum=[$min]"
as the short-cut version will fail:
g.message "minimum=[$min]"
That's unavoidable. If an option value begins with a sequence of
alphanumerics followed immediately by an "=", the option name must be
given.
Similarly, if the option value can be arbitrary text, the option name
must be given both to avoid this issue and to correctly handle the
case where the value starts with a dash.
But none of this changes the fact that the parser failing on e.g.
g.message "v.build map=..."
is a bug, caused by the option=value test using a crude heuristic
(only checking the character immediately prior to the first "="), when
a correct test would actually require less code.
In the above case, the first (and only) argument cannot possibly be an
option=value argument due to the space in the portion before the "=".