[GRASS-dev] [GRASS GIS] #1042: winGRASS: r.statistics complains if path to grassdb has spaces

#1042: winGRASS: r.statistics complains if path to grassdb has spaces
----------------------+-----------------------------------------------------
Reporter: ege | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.0
Component: Raster | Version: svn-releasebranch64
Keywords: wingrass | Platform: MSWindows XP
      Cpu: x86-32 |
----------------------+-----------------------------------------------------
Running r.statistics using a path to GRASS DATABASE folder containing
blank spaces (e.g. C:\Documents and Settings\OCU\Desktop\grassdata)
produces the following error:

{{{
Sorry <and> is not a valid option
Sorry
<Settings/OCU/Desktop/grassdata/leics62/icharm/.tmp/4020.0>
is not a valid option
}}}

After moving "grassdata" to C:\ r.statistics works.

I was going through "GRASS Seeds Training Notes". All other modules I ran
before "r.statistics" did not complain about the path with spaces.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1042&gt;
GRASS GIS <http://grass.osgeo.org>

#1042: winGRASS: r.statistics complains if path to grassdb has spaces
---------------------------+------------------------------------------------
  Reporter: ege | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Raster | Version: svn-releasebranch64
Resolution: | Keywords: wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by glynn):

Replying to [ticket:1042 ege]:
> Running r.statistics using a path to GRASS DATABASE folder containing
blank spaces (e.g. C:\Documents and Settings\OCU\Desktop\grassdata)
produces the following error:

> After moving "grassdata" to C:\ r.statistics works.

This should only affect the sum, average and distribution aggregates; the
others use popen() rather than a temporary file.

Hopefully fixed in 6.5 by r41957. Suggest back-porting to 6.4 for RC7.

Not applicable to 7.0, which doesn't use temporary files.

It might be worthwhile someone doing an exhaustive analysis of calls to
system() and popen() (and the G_* versions) in case any similar issues
remain.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1042#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1042: winGRASS: r.statistics complains if path to grassdb has spaces
---------------------------+------------------------------------------------
  Reporter: ege | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Raster | Version: svn-releasebranch64
Resolution: | Keywords: wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by ege):

Replying to [comment:1 glynn]:
> This should only affect the sum, average and distribution aggregates;
the others use popen() rather than a temporary file.

Yes, I was using average.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1042#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1042: winGRASS: r.statistics complains if path to grassdb has spaces
---------------------------+------------------------------------------------
  Reporter: ege | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Raster | Version: svn-releasebranch64
Resolution: | Keywords: wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by neteler):

ege: In 10-20 minutes from now the new GRASS 6.5.svn winGRASS is online at
http://josef.fsv.cvut.cz/wingrass/grass65/

Could you please try the fixed module?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1042#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#1042: winGRASS: r.statistics complains if path to grassdb has spaces
---------------------------+------------------------------------------------
  Reporter: ege | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Raster | Version: svn-releasebranch64
Resolution: | Keywords: wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by ege):

Replying to [comment:3 neteler]:
> ege: In 10-20 minutes from now the new GRASS 6.5.svn winGRASS is online
at
> http://josef.fsv.cvut.cz/wingrass/grass65/
>
> Could you please try the fixed module?

In winGRASS 6.5 svn the module works :slight_smile:

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1042#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#1042: winGRASS: r.statistics complains if path to grassdb has spaces
---------------------------+------------------------------------------------
  Reporter: ege | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Raster | Version: svn-releasebranch64
Resolution: | Keywords: wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by neteler):

Backported to GRASS 6.4.svn in r41960.

Other candidates:
{{{
d.barscale/main.c: sprintf(cmdbuf, "%s bcolor=%s", cmdbuf,
opt1->answer);
d.barscale/main.c: sprintf(cmdbuf, "%s tcolor=%s", cmdbuf,
opt2->answer);
d.histogram/get_stats.c: cmd = mk_command("r.stats -Cr%s%s \"%s\" >
\"%s\"\n", 4,
d.histogram/get_stats.c: cmd = mk_command("r.stats -r%s%s \"%s\"
nsteps=%s > \"%s\"\n", 5,
d.profile/Range.c: sprintf(stats_cmd, "r.stats -ci %s > %s\n", name,
temp_fname);
d.text.new/main.c: sprintf(buf, "%s < %s", G_recreate_command(),
cmd_file);
r.average/main.c: sprintf(command, "%s -anC input=%s,%s fs=space >
\"%s\"",
r.average/main.c: sprintf(command, "%s input=%s output=%s < \"%s\"",
r.out.mpeg/main.c: sprintf(cmd, "%s %s 2> /dev/null > /dev/null",
encoder, mpfilename);
r.out.mpeg/main.c: sprintf(cmd, "%s %s 2> /dev/null > /dev/null",
encoder, mpfilename);
r.out.mpeg/main.c: sprintf(cmd, "cd %s; \\ls %s >> %s 2>
/dev/null",
xganim/main.c: sprintf(cmd, "cd %s; \\ls %s >> %s 2> /dev/null",
path, wildarg,
}}}

?

Markus

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1042#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#1042: winGRASS: r.statistics complains if path to grassdb has spaces
---------------------------+------------------------------------------------
  Reporter: ege | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Raster | Version: svn-releasebranch64
Resolution: | Keywords: wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by glynn):

Replying to [comment:5 neteler]:
> Other candidates:
>
{{{
d.barscale/main.c: sprintf(cmdbuf, "%s bcolor=%s", cmdbuf,
opt1->answer);
d.barscale/main.c: sprintf(cmdbuf, "%s tcolor=%s", cmdbuf,
opt2->answer);
}}}
The one before that might require it, i.e.:
{{{
         sprintf(cmdbuf, "\"%s\" at=%f,%f", argv[0], east, north);
}}}
>
{{{
d.histogram/get_stats.c: cmd = mk_command("r.stats -Cr%s%s \"%s\" >
\"%s\"\n", 4,
d.histogram/get_stats.c: cmd = mk_command("r.stats -r%s%s \"%s\"
nsteps=%s > \"%s\"\n", 5,
...
r.average/main.c: sprintf(command, "%s -anC input=%s,%s fs=space >
\"%s\"",
r.average/main.c: sprintf(command, "%s input=%s output=%s < \"%s\"",
}}}
These are already quoted sufficiently.
>
{{{
d.profile/Range.c: sprintf(stats_cmd, "r.stats -ci %s > %s\n", name,
temp_fname);
}}}
This needs quoting:
{{{
     sprintf(stats_cmd, "r.stats -ci %s > \"%s\"", name, temp_fname);
}}}
>
{{{
d.text.new/main.c: sprintf(buf, "%s < %s", G_recreate_command(),
cmd_file);
}}}
So does this:
{{{
     sprintf(buf, "%s < \"%s\"", G_recreate_command(), cmd_file);
}}}
>
{{{
r.out.mpeg/main.c: sprintf(cmd, "%s %s 2> /dev/null > /dev/null",
encoder, mpfilename);
r.out.mpeg/main.c: sprintf(cmd, "%s %s 2> /dev/null > /dev/null",
encoder, mpfilename);
r.out.mpeg/main.c: sprintf(cmd, "cd %s; \\ls %s >> %s 2>
/dev/null",
xganim/main.c: sprintf(cmd, "cd %s; \\ls %s >> %s 2> /dev/null",
path, wildarg,
}}}
And all of these; although, I don't think that gee_wildfiles() will work
on Windows in any event, due to Unix-isms. 7.0 uses g.mlist via
G_spawn_ex().

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1042#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#1042: winGRASS: r.statistics complains if path to grassdb has spaces
----------------------+-----------------------------------------------------
Reporter: ege | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.2
Component: Raster | Version: svn-releasebranch64
Keywords: wingrass | Platform: MSWindows XP
      Cpu: x86-32 |
----------------------+-----------------------------------------------------
Changes (by hellik):

  * milestone: 6.4.0 => 6.4.2

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1042#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#1042: winGRASS: r.statistics complains if path to grassdb has spaces
----------------------+-----------------------------------------------------
Reporter: ege | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.2
Component: Raster | Version: svn-releasebranch64
Keywords: wingrass | Platform: MSWindows XP
      Cpu: x86-32 |
----------------------+-----------------------------------------------------

Comment(by hamish):

r.statistics seems working in 6.4svn native wingrass now.

status of other quoting candidates mentioned in previous comments is
unknown, so not closing the bug yet.

I wouldn't worry too much about the G_recreate_command() stuff as it is
just being ledgered the history file.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1042#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>