[GRASS5] Re: [GRASSLIST:8545] Re: d.m - commands output pollute the Grass terminal

Glynn Clements glynn at gclements.plus.com
Thu Oct 13 13:06:26 EDT 2005


Moritz Lennert wrote:

> >>As a side remark, this might be an argument for avoiding arguments
> >>with spaces whenever possible. For example, in d.vect.thematique, it
> >>might be better to find other names for arguments such as 'graduated
> >>colors', 'custom gradient', 'standard deviation', etc.
> > 
> > 
> > No need. Tcl has perfectly good support for lists; there's no reason
> > to treat a command as a string.
> > 
> 
> Well, my remark was meant for the command line, where you have to
> know that you have to put some of the options between quotes because
> there are spaces between them. I just think it would make life
> easier for everyone if we avoid option names with spaces in them...

Some commands will have spaces in the argument values, e.g. r.mapcalc.

It's far more robust to simply ensure that the code correctly handles
arguments which contain spaces (or other metacharacters).

Tcl's exec command takes each word of the command as a separate
function argument (a word is a program, argument, redirection
specifier etc).

Similarly, when the first character in the first argument to Tcl's
open command is a "|" symbol, the remainder of the argument is treated
as a Tcl list where each element is one word of the command.

Constructing a valid command from variables simply means using e.g.:

	set cmd [list $foo $bar]

rather than:

	set cmd "$foo $bar"

as the former will insert braces as requireed to preserve list
structure.

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




More information about the grass-dev mailing list