[GRASS-SVN] r45610 - grass/branches/develbranch_6/scripts/db.in.ogr

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 9 01:01:53 EST 2011


Author: hamish
Date: 2011-03-08 22:01:52 -0800 (Tue, 08 Mar 2011)
New Revision: 45610

Modified:
   grass/branches/develbranch_6/scripts/db.in.ogr/db.in.ogr
Log:
quote variables (bug #1301; merge from relbr64)

Modified: grass/branches/develbranch_6/scripts/db.in.ogr/db.in.ogr
===================================================================
--- grass/branches/develbranch_6/scripts/db.in.ogr/db.in.ogr	2011-03-09 05:59:01 UTC (rev 45609)
+++ grass/branches/develbranch_6/scripts/db.in.ogr/db.in.ogr	2011-03-09 06:01:52 UTC (rev 45610)
@@ -82,9 +82,9 @@
 
 # check if we want to connect to real DB
 if [ ! -z "$GIS_OPT_DB_TABLE" ] ; then
-  INPUT=$GIS_OPT_DB_TABLE
+  INPUT="$GIS_OPT_DB_TABLE"
 else
-  INPUT=$GIS_OPT_DSN
+  INPUT="$GIS_OPT_DSN"
 fi
 
 if [ -z "$GIS_OPT_OUTPUT" ] ; then
@@ -100,7 +100,7 @@
   fi
 else
   # user gave --o
-  db.droptable -f --q ${GIS_OPT_OUTPUT} >/dev/null 2>/dev/null
+  db.droptable -f --q "$GIS_OPT_OUTPUT" >/dev/null 2>/dev/null
 fi
 
 # treat DB as real vector map...
@@ -110,10 +110,12 @@
 
 # check ERRORs and cat and cat_ issues (maybe problem with translated messages)
 # we import faking a map which generates only the attribute table:
+### check-me: is the quoting ok?
 WARNING="`v.in.ogr --q dsn=\"$GIS_OPT_DSN\" $LAYER out=$GIS_OPT_OUTPUT -o --o 2>&1 | grep -i 'ERROR\|cat' | grep -v 'truncated'`"
-if [ ! -z "$WARNING" ] ; then
+`
+if [ -n "$WARNING" ] ; then
    echo "$WARNING"
-   if [ ! -z "$GIS_OPT_DB_TABLE" ] ; then
+   if [ -n "$GIS_OPT_DB_TABLE" ] ; then
       g.message -e "Input DSN <$INPUT> not found or not readable"
    else
       g.message -e "Input table <$INPUT> not found or not readable"
@@ -122,13 +124,13 @@
 fi
 
 # rename "key"  col if requested from "cat" (generated by v.in.ogr) to new name:
-if [ ! -z ${GIS_OPT_KEY} ] ; then
+if [ -n "$GIS_OPT_KEY" ] ; then
    echo "ALTER TABLE $GIS_OPT_OUTPUT ADD COLUMN $GIS_OPT_KEY integer" | db.execute
    echo "UPDATE $GIS_OPT_OUTPUT SET $GIS_OPT_KEY=cat" | db.execute
 fi
 
 # ... and immediately drop the empty geometry
-eval `g.findfile element=vector file=$GIS_OPT_OUTPUT mapset=$MAPSET`
+eval `g.findfile element=vector file="$GIS_OPT_OUTPUT" mapset="$MAPSET"`
 if [ ! "$file" ] ; then
    g.message -e "Something went wrong. Should not happen"
    exit 1
@@ -138,12 +140,12 @@
 fi
 
 # get rid of superfluous auto-added cat column (and cat_ if present)
-db.dropcol --q -f $GIS_OPT_OUTPUT colum=cat >/dev/null 2>/dev/null
+db.dropcol --q -f "$GIS_OPT_OUTPUT" colum=cat >/dev/null 2>/dev/null
 if [ ! -z "$WARNING" ] ; then
-   db.dropcol --q -f $GIS_OPT_OUTPUT colum=cat_ >/dev/null 2>/dev/null
+   db.dropcol --q -f "$GIS_OPT_OUTPUT" colum=cat_ >/dev/null 2>/dev/null
 fi
 
-RECORDS=`db.describe -c $GIS_OPT_OUTPUT | grep '^nrows' | sed 's+ ++g' | cut -d':' -f2`
+RECORDS=`db.describe -c "$GIS_OPT_OUTPUT" | grep '^nrows' | sed 's+ ++g' | cut -d':' -f2`
 g.message "Imported table <$GIS_OPT_OUTPUT> with $RECORDS rows"
 
 exit 0



More information about the grass-commit mailing list