[GRASS-dev] displaying (slightly) broken raster maps in gis.m
Glynn Clements
glynn at gclements.plus.com
Sat Jul 15 20:20:40 EDT 2006
Michael Barton wrote:
> I've removed all extraneous 'eval exec' syntax from gism I think, with the
> exception of the procedures in runandoutput.tcl (attached here for
> convenience because it's small). If I try to clean up the run and runcmd
> procedures here, d.mon bombs in the gism startup. I don't know whether it is
> due to writing to /dev/null or because of d.mon. Could you take a look and
> offer any suggestions? Thanks.
proc run {cmd args} {
# This and runcmd are being used to run command in the background
# These used to go to stdout and stderr
# but we don't want to pollute that console.
# eval exec -- $cmd $args >@ stdout 2>@ stderr
eval exec -- $cmd $args >& /dev/null
}
proc runcmd {cmd args} {
global gronsole
set ci [$gronsole annotate $cmd [list gism running]]
eval run $cmd $args
$gronsole remove_tag $ci running
}
Cases like this, where the arguments are passed as single list, have
to use eval, as exec expects each command-line argument to be a
separate argument. If you removed the eval, it would pass the entire
argument list as a single argument, which won't work.
This isn't a problem, as the "args" syntax (where a procedure's last
parameter is named "args") is guaranteed to construct the list
correctly.
The main point is to apply the same principles to run/runcmd as to
exec, i.e. either pass individual arguments or, if you need to use
e.g. "eval runcmd $cmd $args", ensure that the argument list is
constructed using list operations rather than string concatenation.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list