[GRASS-SVN] r30406 - in grass/trunk/scripts: v.db.addtable
v.db.droptable
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Feb 29 17:44:19 EST 2008
Author: hamish
Date: 2008-02-29 17:44:19 -0500 (Fri, 29 Feb 2008)
New Revision: 30406
Modified:
grass/trunk/scripts/v.db.addtable/v.db.addtable
grass/trunk/scripts/v.db.droptable/v.db.droptable
Log:
gratuitous quoting, etc.
Modified: grass/trunk/scripts/v.db.addtable/v.db.addtable
===================================================================
--- grass/trunk/scripts/v.db.addtable/v.db.addtable 2008-02-29 22:02:58 UTC (rev 30405)
+++ grass/trunk/scripts/v.db.addtable/v.db.addtable 2008-02-29 22:44:19 UTC (rev 30406)
@@ -114,7 +114,7 @@
QUERYLAYER=1
#check if anything is connected:
-v.db.connect $GIS_OPT_MAP -g layer=1 2> /dev/null | grep '^1 ' > /dev/null
+v.db.connect map="$GIS_OPT_MAP" -g 2> /dev/null | grep '^1 ' > /dev/null
if [ $? -ne 0 ] ; then
# nothing defined for layer 1
g.message "Creating new DB connection based on default mapset settings..."
@@ -128,23 +128,23 @@
g.message "Setting default database driver to DBF."
database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'
driver=dbf
- db.connect driver=$driver database=$database
+ db.connect driver="$driver" database="$database"
fi
else
# there is a definition for layer 1, so we check for the user defined layer
- database=`v.db.connect "$GIS_OPT_MAP" -g | grep -w $QUERYLAYER | awk '{print $4}'`
+ database=`v.db.connect map="$GIS_OPT_MAP" -g | grep -w "$QUERYLAYER" | awk '{print $4}'`
if [ -z "database" ] ; then
#nothing on user defined layer, so we use the default mapset settings in this case:
database=`db.connect -p | grep database | cut -d':' -f2`
driver=`db.connect -p | grep driver | cut -d':' -f2`
else
- driver=`v.db.connect "$GIS_OPT_MAP" -g | grep -w $QUERYLAYER | awk '{print $5}'`
+ driver=`v.db.connect map="$GIS_OPT_MAP" -g | grep -w "$QUERYLAYER" | awk '{print $5}'`
fi
fi
#maybe there is already a table linked to the selected layer?
if [ "$GIS_OPT_LAYER" -eq 1 ] ; then
- v.db.connect "$GIS_OPT_MAP" -g 2> /dev/null | grep -w $GIS_OPT_LAYER > /dev/null
+ v.db.connect "$GIS_OPT_MAP" -g 2> /dev/null | grep -w "$GIS_OPT_LAYER" > /dev/null
if [ $? -eq 0 ] ; then
g.message -e "There is already a table linked to layer <$GIS_OPT_LAYER>"
exit 1
@@ -152,7 +152,7 @@
fi
#maybe there is already a table with that name?
-db.tables database=$database driver=$driver 2> /dev/null | grep "^$table$"
+db.tables database="$database" driver="$driver" 2> /dev/null | grep "^$table$"
if [ $? -ne 0 ] ; then
#if not existing, create it:
@@ -176,7 +176,7 @@
fi
fi
- echo "CREATE TABLE $table ($COLUMN_DEF)" | db.execute database=$database driver=$driver
+ echo "CREATE TABLE $table ($COLUMN_DEF)" | db.execute database="$database" driver="$driver"
if [ $? -ne 0 ] ; then
g.message -e "Cannot continue."
exit 1
@@ -184,14 +184,15 @@
fi
# connect the map to the DB:
-v.db.connect map="$GIS_OPT_MAP" database=$database driver=$driver layer="$GIS_OPT_LAYER" table=$table key=cat
+v.db.connect map="$GIS_OPT_MAP" database="$database" driver="$driver" \
+ layer="$GIS_OPT_LAYER" table="$table" key=cat
# finally we have to add cats into the attribute DB to make modules such as v.what.rast happy:
# (creates new row for each vector line):
-v.to.db "$GIS_OPT_MAP" layer=$GIS_OPT_LAYER option=cat col=cat
+v.to.db "$GIS_OPT_MAP" layer="$GIS_OPT_LAYER" option=cat col=cat
g.message "Current attribute table links:"
-v.db.connect -p $GIS_OPT_MAP
+v.db.connect -p "$GIS_OPT_MAP"
# write cmd history:
v.support map="$GIS_OPT_MAP" cmdhist="${CMDLINE}"
Modified: grass/trunk/scripts/v.db.droptable/v.db.droptable
===================================================================
--- grass/trunk/scripts/v.db.droptable/v.db.droptable 2008-02-29 22:02:58 UTC (rev 30405)
+++ grass/trunk/scripts/v.db.droptable/v.db.droptable 2008-02-29 22:44:19 UTC (rev 30406)
@@ -18,7 +18,6 @@
#% description: Removes existing attribute table of a vector map.
#% keywords: vector, database, attribute table
#%End
-
#%flag
#% key: f
#% description: Force removal (required for actual deletion of table)
@@ -30,14 +29,12 @@
#% description: Vector map from which to remove attribute table
#% required : yes
#%end
-
#%option
#% key: table
#% type: string
#% description: Name of existing attribute table (default: vector map name)
#% required : no
#%end
-
#%option
#% key: layer
#% type: integer
@@ -76,12 +73,12 @@
# do some paranoia tests as well:
if [ -z "$GIS_OPT_TABLE" ] ; then
- table=`v.db.connect $GIS_OPT_MAP -g`
+ table=`v.db.connect map="$GIS_OPT_MAP" -g`
if [ $? -ne 0 ] ; then
g.message -e "An error occured while running v.db.connect"
exit 1
fi
- table=`v.db.connect $GIS_OPT_MAP -g | grep -w $GIS_OPT_LAYER | awk '{print $2}'`
+ table=`v.db.connect map="$GIS_OPT_MAP" -g | grep -w "$GIS_OPT_LAYER" | awk '{print $2}'`
if [ -z $table ] ; then
g.message -e "No table assigned to layer <$GIS_OPT_LAYER>"
exit 1
@@ -89,7 +86,7 @@
# Removing table name connected to selected layer
else
# Removing user specified table
- existingtable=`v.db.connect $GIS_OPT_MAP -g | grep -w $GIS_OPT_LAYER | awk '{print $2}'`
+ existingtable=`v.db.connect map="$GIS_OPT_MAP" -g | grep -w "$GIS_OPT_LAYER" | awk '{print $2}'`
table=$GIS_OPT_TABLE
if [ "$existingtable" != "$table" ] ; then
g.message -e "User selected table <$table> but the table <$existingtable> is linked to layer <$GIS_OPT_LAYER>"
@@ -98,13 +95,13 @@
fi
# we use the DB settings selected layer
-database=`v.db.connect $GIS_OPT_MAP -g`
+database=`v.db.connect map="$GIS_OPT_MAP" -g`
if [ $? -ne 0 ] ; then
g.message -e "An error occured while running v.db.connect"
exit 1
fi
-database=`v.db.connect $GIS_OPT_MAP -g | grep -w $GIS_OPT_LAYER | awk '{print $4}'`
-driver=`v.db.connect $GIS_OPT_MAP -g | grep -w $GIS_OPT_LAYER | awk '{print $5}'`
+database=`v.db.connect map="$GIS_OPT_MAP" -g | grep -w "$GIS_OPT_LAYER" | awk '{print $4}'`
+driver=`v.db.connect map="$GIS_OPT_MAP" -g | grep -w "$GIS_OPT_LAYER" | awk '{print $5}'`
g.message "Removing table <$table> linked to layer <$GIS_OPT_LAYER> of vector map <$GIS_OPT_MAP>"
@@ -123,19 +120,19 @@
exit 1
fi
- v.db.connect -d map=$GIS_OPT_MAP layer=$GIS_OPT_LAYER
+ v.db.connect -d map="$GIS_OPT_MAP" layer="$GIS_OPT_LAYER"
g.message "Current attribute table link(s):"
# silently test first to avoid confusing error messages
- v.db.connect --q -p $GIS_OPT_MAP > /dev/null 2> /dev/null
+ v.db.connect --quiet -p map="$GIS_OPT_MAP" > /dev/null 2> /dev/null
if [ $? -ne 0 ] ; then
g.message "(No database links remaining)"
else
- v.db.connect -p $GIS_OPT_MAP
+ v.db.connect -p map="$GIS_OPT_MAP"
fi
# write cmd history:
- v.support ${GIS_OPT_MAP} cmdhist="${CMDLINE}"
+ v.support "${GIS_OPT_MAP}" cmdhist="${CMDLINE}"
else
g.message "Leaving map/table unchanged."
More information about the grass-commit
mailing list