[GRASS5] [bug #1075] (grass) bug in r.mapcalc
Glynn Clements
glynn.clements at virgin.net
Fri May 31 23:51:44 EDT 2002
Markus Neteler wrote:
> > > Problem #3 (or just a note): in a command mode, r.mapcalc behaves
> > > differently than a few months ago. Now you must have a command
> > > without spaces around "=" while in the past this command worked OK:
> > >
> > > GRASS:~ > r.mapcalc flow.dx = "flow * cos(aspect)"
> >
> > I can implement that easily enough.
>
> Thanks Glynn. This saves us from rewriting lots of scripts and
> docs. I just tested:
>
> GRASS:~/cvsgrass_exp > r.mapcalc test="34-43"
> test = (sub(34,43))
> 3%...
> GRASS:~/cvsgrass_exp > r.mapcalc "test=34-43"
> test = (sub(34,43))
> 3%...
>
> nice.
Er, that's just shell behaviour; in both cases, r.mapcalc will get a
single argument.
> > However, given that you have to quote most of the command (e.g. to
> > prevent '*' being expanded by the shell), you may as well just quote
> > the whole thing, i.e.
> >
> > r.mapcalc "flow.dx = flow * cos(aspect)"
>
> Really? For my bash it works:
>
> r.mapcalc test="34 * 43"
> test = (mul(34,43))
Same here, this is still a single argument.
The issue was regarding unquoted spaces in the command line, e.g.:
r.mapcalc test = "34 * 34"
In this case, r.mapcalc would get three arguments, i.e.
argc: 4
argv[0]: "r.mapcalc"
argv[1]: "test"
argv[2]: "="
argv[3]: "34 * 34"
The fix duplicates the behaviour of the old r.mapcalc which, when
given multiple arguments, concatenates them into a single string, then
parses that string.
--
Glynn Clements <glynn.clements at virgin.net>
More information about the grass-dev
mailing list