[GRASS-dev] g.mlist as C implementation?

Glynn Clements glynn at gclements.plus.com
Wed Sep 12 09:06:35 EDT 2007


Hamish wrote:

> > - The script relies on "echo -n"; not portable?
> 
> Instead of "echo -n" to build the output map by map, what if a string was
> constructed within the loop like:
> 
> if [ $first ] ; then
>   OUTSTRING="$MAPNAME$MAPSET"
> else
>   OUTSTRING="$OUTSTRING$SEP$MAPNAME$MAPSET"
> fi
> 
> 
> and then at end of the script just a single
>   echo "$OUTSTRING"
> 
> is that going to max out at 4096 chars?

It's going to create the string in memory, then write it in one go.

It could potentially hit a limit on the maximum length of a command if
echo isn't a built-in. I don't know whether this is anything other
than a theoretical possibility, though.

> what should a the C flat 'g.list -g' output look like? how about:
> [user1]
> map1
> map2
> map3
> [PERMANENT]
> map_a
> map_b
> map_c

It would be simpler to parse if the mapset was part of each name,
e.g.:

map1 at user1
map2 at user1
map3 at user1
map_a at PERMANENT
map_b at PERMANENT
map_c at PERMANENT

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




More information about the grass-dev mailing list