[GRASS-SVN] r34809 - grass/branches/develbranch_6/scripts/v.db.addcol

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 9 05:50:32 EST 2008


Author: neteler
Date: 2008-12-09 05:50:31 -0500 (Tue, 09 Dec 2008)
New Revision: 34809

Modified:
   grass/branches/develbranch_6/scripts/v.db.addcol/v.db.addcol
Log:
trap odd column definitions

Modified: grass/branches/develbranch_6/scripts/v.db.addcol/v.db.addcol
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.addcol/v.db.addcol	2008-12-09 09:40:16 UTC (rev 34808)
+++ grass/branches/develbranch_6/scripts/v.db.addcol/v.db.addcol	2008-12-09 10:50:31 UTC (rev 34809)
@@ -99,7 +99,15 @@
 while [ "$n" -le "$colnum" ]
   do
     col=`echo $GIS_OPT_COLUMNS | cut -d',' -f$n`
-    
+
+    # trap odd column definitions
+    COLPAIRS=`echo $col | tr ',' '\n' | wc -l | awk '{print $1 * 2}'`
+    TOKENS=`echo $col | tr ' ' '\n' | wc -l | awk '{print $1}'`
+    if [ $COLPAIRS -ne $TOKENS ] ; then
+      g.message -e 'Column definitions are not comma separated or incorrect'
+      exit 1
+    fi
+
     if [ -z "$col" ] ; then
       g.message -e 'There is an empty column! Did you leave a trailing comma?'
       exit 1



More information about the grass-commit mailing list