[GRASS-dev] g.mremove bug?

Glynn Clements glynn at gclements.plus.com
Thu Feb 21 22:58:29 EST 2008


Ivan Shmakov wrote:

> $ g.mlist rast pattern="out_ST*" | sed -e s/^/rast=/ | xargs g.remove 
> 
> 	This variant runs `g.remove' in ``batches'', supplying each time
> 	just enough arguments to reasonably fill the limited command
> 	line space.
> 
> 	The use of `xargs' is safe as long as the arguments don't
> 	contain any of the following characters:
> 
> 	* newlines (ASCII LF, 10) or blanks (ASCII HT, space, etc.), as
> 	  they're used to separate arguments;
> 
> 	* backslashes, single- and double-quote characters, as they're
> 	  used to quote newlines, blanks and themselves.

That isn't a problem; GRASS map names aren't allowed to contain any of
those characters.

The more fundamental problem with using xargs is that the GRASS parser
requires multiple "answers" for any given option to be separated by
commas, not spaces.

That effectively requires g.mremove to collate names itself.

Invoking g.remove once per map is simpler, but it's also inefficient.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list