[GRASS-dev] how to deal with the @mapset in scripts?

Glynn Clements glynn at gclements.plus.com
Tue Jul 3 09:02:27 EDT 2007


"Carlos \"Guâno\" Grohmann" wrote:

> I went look in r.shade.relief, so I changed
> 
> if [ -z `g.findfile elem=cell file="$GIS_OPT_SLOPE" | grep ^file | cut
> -f2 -d=` ] ; then
>     g.message -e "<$GIS_OPT_SLOPE> does not exist! Aborting."
>     exit 1
> fi
> 
> by
> slope=$GIS_OPT_SLOPE
> 
> eval `g.findfile element=cell file=$slope`
> if [ -z "$name" ] ; then
>    g.message -e  "Map <$slope> not found! Aborting."
>    exit 1
> fi
> 
> and now it works fine.

Why do you actually need to use g.findfile? In most cases, you should
just pass the map name directly to the command, and let the command
handle the checking.

Also, if you use g.parser and the options have the appropriate
"gisprompt" setting, g.parser will perform the relevant checks, so
there's no need to repeat them.

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




More information about the grass-dev mailing list