[GRASS-dev] g.mremove bug?

Ivan Shmakov ivan at theory.asu.ru
Thu Feb 21 11:17:44 EST 2008


>>>>> Moritz Lennert <mlennert at club.worldonline.be> writes:

 >> to validate a modelling module I generated output raster (ca. 10000
 >> - but I did not want to look at each of them ,-) )

 >> but when I try to remove them using g.mremove I get:

[...]

	This is a bug in `g.mremove'.

	It may be reasonable to rewrite `g.mremove' using `xargs',
	though unfortunately `xargs' isn't required to support `-0' per
	POSIX [1].

 > The shell has a maximum line length (and maximum argument number ?)
 > which you probably exceed with this list.

	These are usually OS limits, not just that of the shell.

 > You'd probably be better off doing something like this:

 > for map in `g.mlist rast pattern="out_ST*"` ; do g.remove $map ; done

	Or (see also [1-4]):

$ 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.

[1] http://www.opengroup.org/onlinepubs/009695399/utilities/xargs.html
[2] http://www.opengroup.org/onlinepubs/009695399/utilities/sed.html
[3] http://www.gnu.org/software/sed/manual/
[4] http://www.gnu.org/software/findutils/manual/html_node/find_html/Invoking-xargs.html



More information about the grass-dev mailing list