[GRASS-SVN] r30402 - in grass/trunk/scripts: v.db.join v.db.update

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Feb 29 16:40:18 EST 2008


Author: hamish
Date: 2008-02-29 16:40:17 -0500 (Fri, 29 Feb 2008)
New Revision: 30402

Modified:
   grass/trunk/scripts/v.db.join/v.db.join
   grass/trunk/scripts/v.db.update/v.db.update
Log:
quote variables

Modified: grass/trunk/scripts/v.db.join/v.db.join
===================================================================
--- grass/trunk/scripts/v.db.join/v.db.join	2008-02-29 15:19:34 UTC (rev 30401)
+++ grass/trunk/scripts/v.db.join/v.db.join	2008-02-29 21:40:17 UTC (rev 30402)
@@ -79,26 +79,28 @@
    g.message -e "JOIN is not supported for tables stored in DBF format."
    exit 1
 fi
-maptable="`v.db.connect -g $GIS_OPT_MAP layer=$GIS_OPT_LAYER | cut -d' ' -f2`"
+maptable=`v.db.connect -g "$GIS_OPT_MAP" layer="$GIS_OPT_LAYER" | cut -d' ' -f2`
 if [ -z "$maptable" ] ; then
    g.message 'There is no table connected to this map! Cannot join any column.'
    cleanup
    exit 1
 fi
-v.info --q -c $GIS_OPT_MAP layer=$GIS_OPT_LAYER | cut -d'|' -f1,2 | grep "|${GIS_OPT_column}$" 2>&1 >/dev/null
+v.info --quiet -c "$GIS_OPT_MAP" layer="$GIS_OPT_LAYER" | \
+   cut -d'|' -f1,2 | grep "|${GIS_OPT_column}$" 2>&1 >/dev/null
+
 if [ $? -ne 0 ] ; then
-	g.message -e "Column <$GIS_OPT_column> not found in table <$GIS_OPT_MAP> at layer $GIS_OPT_LAYER"
-	exit 1
+    g.message -e "Column <$GIS_OPT_column> not found in table <$GIS_OPT_MAP> at layer $GIS_OPT_LAYER"
+    exit 1
 fi
 
 # we use map DBMI settings
-COLLIST=`db.describe  -c driver=$driver database=$database table=$GIS_OPT_otable | grep '^Column ' | cut -d':' -f2`
+COLLIST=`db.describe  -c driver="$driver" database="$database" table="$GIS_OPT_otable" | grep '^Column ' | cut -d':' -f2`
 # heck, types may have white space
-COLTYPES="`db.describe -c driver=$driver database=$database table=$GIS_OPT_otable | grep '^Column ' | cut -d':' -f3 | tr -s ' ' '_'`"
+COLTYPES=`db.describe -c driver="$driver" database="$database" table="$GIS_OPT_otable" | grep '^Column ' | cut -d':' -f3 | tr -s ' ' '_'`
 
 i=1
 for col in $COLLIST ; do
-  v.db.addcol $GIS_OPT_MAP col="$col `echo $COLTYPES | cut -d' ' -f$i | tr -s '_' ' '`"
+  v.db.addcol "$GIS_OPT_MAP" col="$col `echo $COLTYPES | cut -d' ' -f$i | tr -s '_' ' '`"
   if [ $? -ne 0 ] ; then
 	g.message -e "Cannot continue."
 	exit 1
@@ -109,6 +111,6 @@
 done
 
 # write cmd history:
-v.support ${GIS_OPT_MAP} cmdhist="${CMDLINE}"
+v.support "${GIS_OPT_MAP}" cmdhist="${CMDLINE}"
 
 exit 0

Modified: grass/trunk/scripts/v.db.update/v.db.update
===================================================================
--- grass/trunk/scripts/v.db.update/v.db.update	2008-02-29 15:19:34 UTC (rev 30401)
+++ grass/trunk/scripts/v.db.update/v.db.update	2008-02-29 21:40:17 UTC (rev 30402)
@@ -103,16 +103,16 @@
    exit 1
 fi
 
-table=`v.db.connect $GIS_OPT_MAP -g | grep -w $GIS_OPT_LAYER | awk '{print $2}'`
+table=`v.db.connect "$GIS_OPT_MAP" -g | grep -w "$GIS_OPT_LAYER" | awk '{print $2}'`
 if [ -z "$table" ] ; then
    g.message -e 'There is no table connected to this map! Run v.db.connect or v.db.addtable first.'
    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 "$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}'`
 
 # checking column types
-coltype=`v.info -c map=$GIS_OPT_MAP --q | grep -w $GIS_OPT_COLUMN | cut -d'|' -f1`
+coltype=`v.info -c map="$GIS_OPT_MAP" --quiet | grep -w "$GIS_OPT_COLUMN" | cut -d'|' -f1`
 if [ -n "$GIS_OPT_QCOLUMN" ] ; then
    if [ -n "$GIS_OPT_VALUE" ] ; then
       g.message -e 'Either value or qcolumn parameter have to be used'
@@ -123,20 +123,22 @@
 else
    # we insert a value
    if [ "$coltype" = "INTEGER" -o "$coltype" = "DOUBLE PRECISION" ] ; then
-       value=$GIS_OPT_VALUE
+       value="$GIS_OPT_VALUE"
    else
-       value=\'$GIS_OPT_VALUE\'
+       value="'$GIS_OPT_VALUE'"
    fi
 fi
 
 if [ -n "$GIS_OPT_WHERE" ]
   then
-    echo "UPDATE $table SET $GIS_OPT_COLUMN=$value WHERE $GIS_OPT_WHERE" | db.execute database=$database driver=$driver
+    echo "UPDATE $table SET $GIS_OPT_COLUMN=$value WHERE $GIS_OPT_WHERE" |
+       db.execute database="$database" driver="$driver"
 else
-    echo "UPDATE $table SET $GIS_OPT_COLUMN=$value" | db.execute database=$database driver=$driver
+    echo "UPDATE $table SET $GIS_OPT_COLUMN=$value" | \
+       db.execute database="$database" driver="$driver"
 fi
 
 # 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