|
@@ -1,151 +0,0 @@
|
|
|
-#!/bin/sh
|
|
|
-#
|
|
|
-############################################################################
|
|
|
-#
|
|
|
-# MODULE: g.mremove
|
|
|
-# AUTHOR(S): Huidae Cho - grass4u@gmail.com
|
|
|
-# PURPOSE: Removes data files using basic regular expressions and wildcards
|
|
|
-# COPYRIGHT: (C) 2000 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.
|
|
|
-#
|
|
|
-#############################################################################
|
|
|
-
|
|
|
-
|
|
|
-#%Module
|
|
|
-#% description: Removes data files using basic regular expressions and wildcards.
|
|
|
-#% keywords: general, map management
|
|
|
-#%End
|
|
|
-
|
|
|
-#%flag
|
|
|
-#% key: r
|
|
|
-#% description: Use basic regular expressions instead of wildcards
|
|
|
-#%end
|
|
|
-
|
|
|
-#%flag
|
|
|
-#% key: f
|
|
|
-#% description: Force removal (required for actual deletion of files)
|
|
|
-#%end
|
|
|
-
|
|
|
-#%option
|
|
|
-#% key: rast
|
|
|
-#% type: string
|
|
|
-#% description: Raster to remove
|
|
|
-#% gisprompt: old,cell,raster
|
|
|
-#% required : no
|
|
|
-#%end
|
|
|
-
|
|
|
-#%option
|
|
|
-#% key: rast3d
|
|
|
-#% type: string
|
|
|
-#% description: 3d raster to remove
|
|
|
-#% gisprompt: old,grid3,3d-raster
|
|
|
-#% required : no
|
|
|
-#%end
|
|
|
-
|
|
|
-#%option
|
|
|
-#% key: vect
|
|
|
-#% type: string
|
|
|
-#% description: Vector to remove
|
|
|
-#% gisprompt: old,vector,vector
|
|
|
-#% required : no
|
|
|
-#%end
|
|
|
-
|
|
|
-#%option
|
|
|
-#% key: region
|
|
|
-#% type: string
|
|
|
-#% description: Region to remove
|
|
|
-#% required : no
|
|
|
-#%end
|
|
|
-
|
|
|
-#%option
|
|
|
-#% key: icon
|
|
|
-#% type: string
|
|
|
-#% description: Icon to remove
|
|
|
-#% required : no
|
|
|
-#%end
|
|
|
-
|
|
|
-#%option
|
|
|
-#% key: label
|
|
|
-#% type: string
|
|
|
-#% description: Label to remove
|
|
|
-#% required : no
|
|
|
-#%end
|
|
|
-
|
|
|
-#%option
|
|
|
-#% key: dview
|
|
|
-#% type: string
|
|
|
-#% description: 3dview to remove
|
|
|
-#% required : no
|
|
|
-#%end
|
|
|
-
|
|
|
-#%option
|
|
|
-#% key: group
|
|
|
-#% type: string
|
|
|
-#% description: Group to remove
|
|
|
-#% required : no
|
|
|
-#%end
|
|
|
-
|
|
|
-if [ "$1" != "@ARGS_PARSED@" ] ; then
|
|
|
- exec g.parser "$0" "$@"
|
|
|
-fi
|
|
|
-
|
|
|
-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
|
|
|
-
|
|
|
-g.message "Collecting map names for current mapset <$MAPSET>..."
|
|
|
-
|
|
|
-if [ $GIS_FLAG_R -eq 1 ] ; then
|
|
|
- regex="-r"
|
|
|
-else
|
|
|
- regex=""
|
|
|
-fi
|
|
|
-
|
|
|
-force=$GIS_FLAG_F
|
|
|
-
|
|
|
-if [ $force -eq 1 ] ; then
|
|
|
- g.message "Forcing ..."
|
|
|
-fi
|
|
|
-
|
|
|
-found=""
|
|
|
-
|
|
|
-search() {
|
|
|
- if [ ! "$2" ]; then
|
|
|
- return
|
|
|
- fi
|
|
|
- found="$found"`
|
|
|
- g.mlist $regex sep=, mapset="$MAPSET" type="$1" pattern="$2" |
|
|
|
- sed "s,^\(.\), $1=\1,"`
|
|
|
-}
|
|
|
-
|
|
|
-search rast "$GIS_OPT_RAST"
|
|
|
-search rast3d "$GIS_OPT_RAST3D"
|
|
|
-search vect "$GIS_OPT_VECT"
|
|
|
-search icon "$GIS_OPT_ICON"
|
|
|
-search labels "$GIS_OPT_LABEL"
|
|
|
-search region "$GIS_OPT_REGION"
|
|
|
-search group "$GIS_OPT_GROUP"
|
|
|
-search 3dview "$GIS_OPT_DVIEW"
|
|
|
-
|
|
|
-if [ ! "$found" ] ; then
|
|
|
- g.message -e "No data found."
|
|
|
- exit 1
|
|
|
-fi
|
|
|
-
|
|
|
-if [ $force -eq 0 ] ; then
|
|
|
- g.message "The following files would be deleted:"
|
|
|
- echo "g.remove $found"
|
|
|
- g.message message=""
|
|
|
- g.message "You must use the force flag to actually remove them. Exiting."
|
|
|
- exit 0
|
|
|
-fi
|
|
|
-
|
|
|
-exec g.remove $found
|