[GRASS-user] SHELL variable not set

Markus Neteler neteler at osgeo.org
Tue Jan 29 06:08:29 EST 2008


On Jan 29, 2008 11:42 AM, Hamish <hamish_b at yahoo.com> wrote:
> Martin Wegmann wrote:
> > unfortunately I added 'rm .* ' instead of a 'rm $variable.*' in a
> > GRASS script, hence I had to setup a new user account
>
> just to highlight the trap, as I've fallen into it too:
>
> if $variable is unset for some reason, 'rm "$variable".*' becomes
> 'rm "".*' which is processed by the shell as 'rm .*'
>
> lesson: be very careful with rm, try to anticiapte failure modes, and
> set up that rsync cron job to backup your home directory.

... and maybe do $variable testing in the script, e.g.

if  [ -z "$variable" ] ; then
    echo "variable not set"
else
    rm -f "$variable".*
fi

Markus


More information about the grass-user mailing list