[GRASS-user] Re: How to best access hundreds of orthophotos -- mapserver as WMS server?

Ivan Shmakov ivan at theory.asu.ru
Mon Dec 17 12:05:29 EST 2007


>>>>> Glynn Clements <glynn at gclements.plus.com> writes:

 >>> Also the "for MAP in ``" method would need to be changed if there
 >>> are thousands of maps?

 >> I don't think so.  Since the `for' command is internal to the Shell,
 >> there's no command line to be passed to any other process, and so
 >> there're no command line length limits in force.

 >> Still, using COMMAND | while read VARN ; do ...; done looks more
 >> clean to me.

 > The while/read approach saves keeping the list of maps in
 > memory. Once upon a time, that might have mattered; with modern
 > systems, you would need millions of maps before it became an issue.

	``while read'' saves one from using one level of backquotes,
	thus, in my opinion, making the code a bit more readable.

	Consider:

for r in `g.mlist pattern="example-\`date +%Y-%m-%d\`-*"`; do
    ...
done

g.mlist pattern="example-`date +%Y-%m-%d`-*" | while read r; do
    ...
done

	Besides, the body of a ``while read'' loop is executed ``in
	parallel'' to the command to the left of the pipe.  On the
	contrary, the ``for'' pattern will wait until the command inside
	of the backquotes completes.

	There're whitespace issues, though hardly relevant to the
	`g.mlist' case.



More information about the grass-user mailing list