[GRASS-SVN] r43497 - grass/branches/releasebranch_6_4/scripts/v.db.addcol

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 18 10:45:02 EDT 2010


Author: neteler
Date: 2010-09-18 14:45:02 +0000 (Sat, 18 Sep 2010)
New Revision: 43497

Modified:
   grass/branches/releasebranch_6_4/scripts/v.db.addcol/v.db.addcol
Log:
backport cosmetics in parameter description; quote some variables

Modified: grass/branches/releasebranch_6_4/scripts/v.db.addcol/v.db.addcol
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.db.addcol/v.db.addcol	2010-09-18 14:42:38 UTC (rev 43496)
+++ grass/branches/releasebranch_6_4/scripts/v.db.addcol/v.db.addcol	2010-09-18 14:45:02 UTC (rev 43497)
@@ -25,14 +25,16 @@
 #% type: string
 #% gisprompt: old,vector,vector
 #% key_desc : name
-#% description: Vector map for which to edit attribute table
+#% description: Name of vector map for which to edit attribute table
 #% required : yes
 #%end
 
 #%option
 #% key: layer
 #% type: integer
-#% description: Layer where to add column
+#% gisprompt: old_layer,layer,layer
+#% label: Layer number where to add column(s)
+#% description: A single vector map can be connected to multiple database tables. This number determines which table to use.
 #% answer: 1
 #% required : no
 #%end
@@ -40,7 +42,8 @@
 #%option
 #% key: columns
 #% type: string
-#% description: Name and type of the new column(s) (types depend on database backend, but all support VARCHAR(), INT, DOUBLE PRECISION and DATE)
+#% label: Name and type of the new column(s) ('name type [,name type, ...]')
+#% description: Data types depend on database backend, but all support VARCHAR(), INT, DOUBLE PRECISION and DATE
 #% required : yes
 #%end
 
@@ -78,7 +81,7 @@
 : ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
 
 # does map exist in CURRENT mapset?
-eval `g.findfile element=vector file=$GIS_OPT_MAP mapset=$MAPSET`
+eval `g.findfile element=vector file="$GIS_OPT_MAP" mapset="$MAPSET"`
 if [ ! "$file" ] ; then
    g.message "Vector map '$GIS_OPT_MAP' not found in current mapset"
    exit 1
@@ -93,19 +96,19 @@
 database=`v.db.connect "$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $4}'`
 driver=`v.db.connect "$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $5}'`
 
-colnum=`echo $GIS_OPT_COLUMNS | awk -F, '{print NF}'`
+colnum=`echo "$GIS_OPT_COLUMNS" | awk -F, '{print NF}'`
 
 n=1
 while [ "$n" -le "$colnum" ]
   do
-    col=`echo $GIS_OPT_COLUMNS | cut -d',' -f$n`
+    col=`echo "$GIS_OPT_COLUMNS" | cut -d',' -f$n`
     
     if [ -z "$col" ] ; then
       g.message -e 'There is an empty column! Did you leave a trailing comma?'
       exit 1
     fi
 
-    echo "ALTER TABLE $table ADD COLUMN $col" | db.execute database="${database}" driver=${driver}
+    echo "ALTER TABLE $table ADD COLUMN $col" | db.execute database="${database}" driver="${driver}"
     if [ $? -eq 1 ] ; then
       g.message -e "Cannot continue (problem adding column)."
       exit 1
@@ -115,7 +118,7 @@
 
 
 # write cmd history:
-v.support ${GIS_OPT_MAP} cmdhist="${CMDLINE}"
+v.support "${GIS_OPT_MAP}" cmdhist="${CMDLINE}"
 
 exit 0
 



More information about the grass-commit mailing list