#!/bin/sh
############################################################################
#
# MODULE:	v.build.all
# AUTHOR(S):	Radim Blazek
# PURPOSE:	Build all vectors in current mapset
# COPYRIGHT:	(C) 2004 by the GRASS Development Team
#
#		This program is free software under the GNU General Public
#		License (>=v2). Read the file COPYING that comes with GRASS
#		for details.
#
#############################################################################

if test "$GISBASE" = ""; then
    echo "You must be in GRASS GIS to run this program." >&2
    exit 1
fi

eval `g.gisenv`
: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
LOCATION=$GISDBASE/$LOCATION_NAME/$MAPSET

if [ $# -eq 0 -o $1 = "-h" -o $1 = "help" -o $1 = "-help" ] ; then
  if [ "$1" != "@ARGS_PARSED@" ] ; then
     exec g.parser "$0" "$@"
  fi
fi

for VECT in `g.list type=vect mapset=${MAPSET} | sed 1,2d | grep -v '^-*$'`
do
    echo "Build topology for vector '${VECT}@${MAPSET}'"
    CMD="v.build map=${VECT}@${MAPSET}"
    echo $CMD
    $CMD
done

exit 0

