[GRASS-SVN] r40308 - grass/branches/develbranch_6/scripts/v.db.addtable

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 8 00:19:54 EST 2010


Author: hamish
Date: 2010-01-08 00:19:53 -0500 (Fri, 08 Jan 2010)
New Revision: 40308

Modified:
   grass/branches/develbranch_6/scripts/v.db.addtable/v.db.addtable
Log:
don't use v.db.connect as it expands $VARIABLES in db name

Modified: grass/branches/develbranch_6/scripts/v.db.addtable/v.db.addtable
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.addtable/v.db.addtable	2010-01-07 22:16:32 UTC (rev 40307)
+++ grass/branches/develbranch_6/scripts/v.db.addtable/v.db.addtable	2010-01-08 05:19:53 UTC (rev 40308)
@@ -125,13 +125,16 @@
    driver=`db.connect -p | grep '^driver' | cut -d':' -f2`
 else
    # there is a definition for layer 1, so we check for the user defined layer
-   database=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "$QUERYLAYER" | awk -F ";" '{print $4}'`
+   # v.db.connect expands $VARIABLES, we want to keep them relative so use the raw file
+   eval `g.findfile elem="vector/$GIS_OPT_MAP" file=dbln`
+   database=`grep -w "^$QUERYLAYER" "$file" | cut -f4- -d' ' | sed -e 's/ [^ ]*$//'`
+
    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 map="$GIS_OPT_MAP" -g fs=";" | grep -w "$QUERYLAYER" | awk -F ";" '{print $5}'`
+       driver=`grep -w "^$QUERYLAYER" "$file" | sed -e 's/^.* \(.*\)$/\1/'`
    fi
 fi
 
@@ -182,7 +185,8 @@
 
 # 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 qlayer="$GIS_OPT_LAYER"
+v.to.db "$GIS_OPT_MAP" layer="$GIS_OPT_LAYER" option=cat \
+   col=cat qlayer="$GIS_OPT_LAYER"
 
 if [ -z "$GRASS_VERBOSE" ] || [ "$GRASS_VERBOSE" -gt 0 ] ; then
    g.message "Current attribute table links:"



More information about the grass-commit mailing list