r.sum produced result with spaces:
SUM = 8787936.000000
which makes it hard parable for shell scripts:
eval `r.sum rast=soils --q`
bash: SUM: command not found
IMHO there is no barrier to remove this white spaces, so the that result
looks like
SUM=8787936.000000
and one can easily perform something like
eval `r.sum rast=soils --q`
echo $SUM
8787936.000000
I allready sent this to cvs - I'm just asking, to be sure.
Jachym,
This is certainly a good approach what you have done, but I'm not
really sure such changes should be allowed during 6.x. Maybe postpone
it until GRASS 7? There might be users scripts that use r.sum and we
never know how they parse r.sum's output. But maybe I'm just too
cautious. What do others think?
Thanks for the huge portion of your recent cleanups and fixes in the
CVS! Great job!
Jachym wrote:
> r.sum produced result with spaces:
> SUM = 8787936.000000
>
> which makes it hard parable for shell scripts:
> eval `r.sum rast=soils --q`
> bash: SUM: command not found
>
> IMHO there is no barrier to remove this white spaces, so the that
> result looks like
> SUM=8787936.000000
>
> and one can easily perform something like
> eval `r.sum rast=soils --q`
> echo $SUM
> 8787936.000000
>
> I allready sent this to cvs - I'm just asking, to be sure.
Maciek:
This is certainly a good approach what you have done, but I'm not
really sure such changes should be allowed during 6.x. Maybe postpone
it until GRASS 7? There might be users scripts that use r.sum and we
never know how they parse r.sum's output. But maybe I'm just too
cautious. What do others think?
cautious is good. This module is very likely to be used in scripts, so
I'd suggest keeping it's output the same during GRASS 6.x.
just guessing how folks might parse that currently,
awk '{print $3}'
or
cut -f3 -d' '
or
...?
If parsable output is desired, add a "-g" flag to do that.
As this module gives the same result as r.univar, for future development
I suggest depreciating the module and recommending the user just use
r.univar instead of r.sum. It is slightly slower but the more code
consolidation we do the better IMO.
allright,
as usage of r.sum is deprecated, I added one line with comment to the
module and put the whitespaces back
jachym
On Mon, Nov 27, 2006 at 02:39:28PM +1300, Hamish wrote:
> Jachym wrote:
> > r.sum produced result with spaces:
> > SUM = 8787936.000000
> >
> > which makes it hard parable for shell scripts:
> > eval `r.sum rast=soils --q`
> > bash: SUM: command not found
> >
> > IMHO there is no barrier to remove this white spaces, so the that
> > result looks like
> > SUM=8787936.000000
> >
> > and one can easily perform something like
> > eval `r.sum rast=soils --q`
> > echo $SUM
> > 8787936.000000
> >
> > I allready sent this to cvs - I'm just asking, to be sure.
Maciek:
> This is certainly a good approach what you have done, but I'm not
> really sure such changes should be allowed during 6.x. Maybe postpone
> it until GRASS 7? There might be users scripts that use r.sum and we
> never know how they parse r.sum's output. But maybe I'm just too
> cautious. What do others think?
cautious is good. This module is very likely to be used in scripts, so
I'd suggest keeping it's output the same during GRASS 6.x.
just guessing how folks might parse that currently,
awk '{print $3}'
or
cut -f3 -d' '
or
...?
If parsable output is desired, add a "-g" flag to do that.
As this module gives the same result as r.univar, for future development
I suggest depreciating the module and recommending the user just use
r.univar instead of r.sum. It is slightly slower but the more code
consolidation we do the better IMO.