[GRASS-windows] whitespace bug?

Markus Neteler neteler at osgeo.org
Wed Oct 22 07:45:52 EDT 2008


On Wed, Oct 22, 2008 at 1:02 PM, Stefan Muthers
<stefan.muthers at zamg.ac.at> wrote:
...

(v.in.ogr works)

I have inserted a white space in my grassdata/ path on Linux and can replicate
your problem:

> I figured out, that in general there s a problem when using a grass
> workspace with whitespace in the path.
> For example:
>  - copy the workspace from above to C:/Dokumente und
>     Einstellungen/muthers/Desktop/grass
>  - open it with grass
>
> $ v.db.addcol map=test columns='test INT'
>
> ERROR: value <und> out of range for parameter <driver>
>       Legal range: dbf,ogr,pg,sqlite

Yes, because in v.db.addcol and many other scripts, the following is called:

v.db.connect test2 -g
1 test2 cat /home/neteler/grass data/spearfish60/neteler/dbf/ dbf

The output is parsed based on white space, indeed the script line looks
like this:
database=`v.db.connect $GIS_OPT_MAP -g | grep -w $GIS_OPT_LAYER | awk
'{print $4}'`

Since awk uses white space here, it separates on the wrong column.

Proposed solution (@ grass-devs):

* revisit all scripts and add fs=";" to v.db.connect -g and use
 that as field separator also for awk (-F ';'), so:
 database=`v.db.connect $GIS_OPT_MAP -g fs=";" | grep -w
$GIS_OPT_LAYER | awk -F ";" '{print $4}'`
* Likewise for driver=...
* and use ... db.execute database="${database}" driver=${driver}
everywhere instead of
  ... db.execute database=$database driver=$driver

diff:
@@ -90,8 +90,8 @@
    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 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}'`

@@ -105,7 +105,7 @@
       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


Then it works.

Markus


More information about the grass-windows mailing list