[GRASS-SVN] r40312 - in grass/branches/releasebranch_6_4/scripts:
d.vect.thematic v.db.addcol v.db.addtable v.db.dropcol
v.db.droptable v.db.reconnect.all v.db.renamecol v.db.update
v.dissolve v.out.gpsbabel v.rast.stats v.report
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jan 8 03:31:29 EST 2010
Author: hamish
Date: 2010-01-08 03:31:26 -0500 (Fri, 08 Jan 2010)
New Revision: 40312
Modified:
grass/branches/releasebranch_6_4/scripts/d.vect.thematic/d.vect.thematic
grass/branches/releasebranch_6_4/scripts/v.db.addcol/v.db.addcol
grass/branches/releasebranch_6_4/scripts/v.db.addtable/v.db.addtable
grass/branches/releasebranch_6_4/scripts/v.db.dropcol/v.db.dropcol
grass/branches/releasebranch_6_4/scripts/v.db.droptable/v.db.droptable
grass/branches/releasebranch_6_4/scripts/v.db.reconnect.all/v.db.reconnect.all
grass/branches/releasebranch_6_4/scripts/v.db.renamecol/v.db.renamecol
grass/branches/releasebranch_6_4/scripts/v.db.update/v.db.update
grass/branches/releasebranch_6_4/scripts/v.dissolve/v.dissolve
grass/branches/releasebranch_6_4/scripts/v.out.gpsbabel/v.out.gpsbabel
grass/branches/releasebranch_6_4/scripts/v.rast.stats/v.rast.stats
grass/branches/releasebranch_6_4/scripts/v.report/v.report
Log:
merge r40310,r40311 shell script safety from devbr6
Modified: grass/branches/releasebranch_6_4/scripts/d.vect.thematic/d.vect.thematic
===================================================================
--- grass/branches/releasebranch_6_4/scripts/d.vect.thematic/d.vect.thematic 2010-01-08 08:11:19 UTC (rev 40311)
+++ grass/branches/releasebranch_6_4/scripts/d.vect.thematic/d.vect.thematic 2010-01-08 08:31:26 UTC (rev 40312)
@@ -361,9 +361,9 @@
export GRASS_PNG_AUTO_WRITE
fi
-table=`v.db.connect $GIS_OPT_MAP -g fs=";" | grep -w $GIS_OPT_LAYER | awk -F ";" '{print $2}'`
-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}'`
+table=`v.db.connect $GIS_OPT_MAP -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
+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}'`
if [ -z "$table" ]
then
Modified: grass/branches/releasebranch_6_4/scripts/v.db.addcol/v.db.addcol
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.db.addcol/v.db.addcol 2010-01-08 08:11:19 UTC (rev 40311)
+++ grass/branches/releasebranch_6_4/scripts/v.db.addcol/v.db.addcol 2010-01-08 08:31:26 UTC (rev 40312)
@@ -84,14 +84,14 @@
exit 1
fi
-table=`v.db.connect $GIS_OPT_MAP -g fs=";" | grep -w $GIS_OPT_LAYER | awk -F ";" '{print $2}'`
+table=`v.db.connect "$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{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 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}'`
+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}'`
Modified: grass/branches/releasebranch_6_4/scripts/v.db.addtable/v.db.addtable
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.db.addtable/v.db.addtable 2010-01-08 08:11:19 UTC (rev 40311)
+++ grass/branches/releasebranch_6_4/scripts/v.db.addtable/v.db.addtable 2010-01-08 08:31:26 UTC (rev 40312)
@@ -127,7 +127,11 @@
# there is a definition for layer 1, so we check for the user defined layer
# 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 [ ! "$file" ] ; then
+ database=""
+ else
+ database=`grep -w "^$QUERYLAYER" "$file" | cut -f4- -d' ' | sed -e 's/ [^ ]*$//'`
+ fi
if [ -z "$database" ] ; then
#nothing on user defined layer, so we use the default mapset settings in this case:
@@ -140,7 +144,7 @@
#maybe there is already a table linked to the selected layer?
if [ "$GIS_OPT_LAYER" -eq 1 ] ; then
- v.db.connect "$GIS_OPT_MAP" -g 2> /dev/null | grep -w "$GIS_OPT_LAYER" > /dev/null
+ v.db.connect "$GIS_OPT_MAP" -g 2> /dev/null | grep -w "^$GIS_OPT_LAYER" > /dev/null
if [ $? -eq 0 ] ; then
g.message -e "There is already a table linked to layer <$GIS_OPT_LAYER>"
exit 1
Modified: grass/branches/releasebranch_6_4/scripts/v.db.dropcol/v.db.dropcol
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.db.dropcol/v.db.dropcol 2010-01-08 08:11:19 UTC (rev 40311)
+++ grass/branches/releasebranch_6_4/scripts/v.db.dropcol/v.db.dropcol 2010-01-08 08:31:26 UTC (rev 40312)
@@ -97,15 +97,15 @@
exit 1
fi
-table=`v.db.connect map=$GIS_OPT_MAP -g fs=";" | grep -w $GIS_OPT_LAYER | cut -f2 -d";"`
+table=`v.db.connect map=$GIS_OPT_MAP -g fs=";" | grep -w "^$GIS_OPT_LAYER" | cut -f2 -d";"`
if [ -z "$table" ] ; then
g.message -e 'There is no table connected to the input vector map! Cannot delete any column'
cleanup
exit 1
fi
-keycol=`v.db.connect -g fs=";" map=$GIS_OPT_MAP | grep -w $GIS_OPT_LAYER | cut -f3 -d';'`
-database=`v.db.connect -g fs=";" map=$GIS_OPT_MAP | grep -w $GIS_OPT_LAYER | cut -f4 -d';'`
-driver=`v.db.connect -g fs=";" map=$GIS_OPT_MAP | grep -w $GIS_OPT_LAYER | cut -f5 -d';'`
+keycol=`v.db.connect -g fs=";" map=$GIS_OPT_MAP | grep -w "^$GIS_OPT_LAYER" | cut -f3 -d';'`
+database=`v.db.connect -g fs=";" map=$GIS_OPT_MAP | grep -w "^$GIS_OPT_LAYER" | cut -f4 -d';'`
+driver=`v.db.connect -g fs=";" map=$GIS_OPT_MAP | grep -w "^$GIS_OPT_LAYER" | cut -f5 -d';'`
col="$GIS_OPT_COLUMN"
if [ "$col" = "$keycol" ] ; then
Modified: grass/branches/releasebranch_6_4/scripts/v.db.droptable/v.db.droptable
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.db.droptable/v.db.droptable 2010-01-08 08:11:19 UTC (rev 40311)
+++ grass/branches/releasebranch_6_4/scripts/v.db.droptable/v.db.droptable 2010-01-08 08:31:26 UTC (rev 40312)
@@ -78,7 +78,7 @@
g.message -e "An error occured while running v.db.connect"
exit 1
fi
- table=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
+ table=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
if [ -z "$table" ] ; then
g.message -e "No table assigned to layer <$GIS_OPT_LAYER>"
exit 1
@@ -86,7 +86,7 @@
# Removing table name connected to selected layer
else
# Removing user specified table
- existingtable=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
+ existingtable=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
table="$GIS_OPT_TABLE"
if [ "$existingtable" != "$table" ] ; then
g.message -e "User selected table <$table> but the table <$existingtable> is linked to layer <$GIS_OPT_LAYER>"
@@ -100,8 +100,8 @@
g.message -e "An error occured while running v.db.connect"
exit 1
fi
-database=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "$GIS_OPT_LAYER" | awk -F ";" '{print $4}'`
-driver=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "$GIS_OPT_LAYER" | awk -F ";" '{print $5}'`
+database=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $4}'`
+driver=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $5}'`
g.message "Removing table <$table> linked to layer <$GIS_OPT_LAYER> of vector map <$GIS_OPT_MAP>"
Modified: grass/branches/releasebranch_6_4/scripts/v.db.reconnect.all/v.db.reconnect.all
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.db.reconnect.all/v.db.reconnect.all 2010-01-08 08:11:19 UTC (rev 40311)
+++ grass/branches/releasebranch_6_4/scripts/v.db.reconnect.all/v.db.reconnect.all 2010-01-08 08:31:26 UTC (rev 40312)
@@ -73,8 +73,7 @@
for VECT in `g.list type=vect mapset=${MAPSET} | sed 1,2d | grep -v '^-*$'`
do
g.message message="Reconnecting vector '${VECT}@${MAPSET}'"
- for LINK in `v.db.connect -g fs=";" map=${VECT}@${MAPSET} | tr ';' '|'`
- do
+ for LINK in `v.db.connect -g fs="|" map=${VECT}@${MAPSET}` ; do
eval `echo $LINK | sed 's$\([^\|]*\)|\([^\|]*\)|\([^\|]*\)|\([^\|]*\)|\([^\|]*\)$LAYER=\1 SCHEMA_TABLE=\2 KEY=\3 DATABASE=\4 DRIVER=\5$'`
SCHEMA=`echo $SCHEMA_TABLE | grep '\.' | sed 's/\([^.]*\)\..*/\1/'`
Modified: grass/branches/releasebranch_6_4/scripts/v.db.renamecol/v.db.renamecol
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.db.renamecol/v.db.renamecol 2010-01-08 08:11:19 UTC (rev 40311)
+++ grass/branches/releasebranch_6_4/scripts/v.db.renamecol/v.db.renamecol 2010-01-08 08:31:26 UTC (rev 40312)
@@ -102,16 +102,16 @@
exit 1
fi
-table="`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w "$GIS_OPT_LAYER" | cut -f2 -d';'`"
+table="`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w "^$GIS_OPT_LAYER" | cut -f2 -d';'`"
if [ -z "$table" ] ; then
g.message -e 'There is no table connected to the input vector map! Cannot rename any column'
cleanup
exit 1
fi
-keycol=`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w $GIS_OPT_LAYER | cut -f3 -d';'`
-database="`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w $GIS_OPT_LAYER | cut -f4 -d';'`"
-driver=`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w $GIS_OPT_LAYER | cut -f5 -d';'`
+keycol=`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w "^$GIS_OPT_LAYER" | cut -f3 -d';'`
+database="`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w ^$GIS_OPT_LAYER | cut -f4 -d';'`"
+driver=`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w "^$GIS_OPT_LAYER" | cut -f5 -d';'`
oldcol="`echo $GIS_OPT_COLUMN | cut -d',' -f1`"
newcol="`echo $GIS_OPT_COLUMN | cut -d',' -f2`"
Modified: grass/branches/releasebranch_6_4/scripts/v.db.update/v.db.update
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.db.update/v.db.update 2010-01-08 08:11:19 UTC (rev 40311)
+++ grass/branches/releasebranch_6_4/scripts/v.db.update/v.db.update 2010-01-08 08:31:26 UTC (rev 40312)
@@ -99,14 +99,14 @@
exit 1
fi
-table=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
+table=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{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 map="$GIS_OPT_MAP" -g fs=";" | grep -w "$GIS_OPT_LAYER" | awk -F ";" '{print $4}'`
-driver=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "$GIS_OPT_LAYER" | awk -F ";" '{print $5}'`
+database=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $4}'`
+driver=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $5}'`
# checking column types
coltype=`v.info -c map="$GIS_OPT_MAP" layer=$GIS_OPT_LAYER --quiet | grep -w "$GIS_OPT_COLUMN" | cut -d'|' -f1`
Modified: grass/branches/releasebranch_6_4/scripts/v.dissolve/v.dissolve
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.dissolve/v.dissolve 2010-01-08 08:11:19 UTC (rev 40311)
+++ grass/branches/releasebranch_6_4/scripts/v.dissolve/v.dissolve 2010-01-08 08:31:26 UTC (rev 40312)
@@ -102,7 +102,7 @@
exit 1
fi
- table=`v.db.connect $GIS_OPT_INPUT -g fs=";" | grep -w $GIS_OPT_LAYER | awk -F ";" '{print $2}'`
+ table=`v.db.connect $GIS_OPT_INPUT -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
if [ -z "$table" ] ; then
g.message -e 'There is no table connected to this map!'
exit 1
Modified: grass/branches/releasebranch_6_4/scripts/v.out.gpsbabel/v.out.gpsbabel
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.out.gpsbabel/v.out.gpsbabel 2010-01-08 08:11:19 UTC (rev 40311)
+++ grass/branches/releasebranch_6_4/scripts/v.out.gpsbabel/v.out.gpsbabel 2010-01-08 08:31:26 UTC (rev 40312)
@@ -266,12 +266,12 @@
# don't v.db.connect directly as source table will be removed with
# temporary map in that case. So we make a temp copy of it to work with.
-DB_PARAMS=`v.db.connect -g "$INMAP" 2> /dev/null | grep "^$GIS_OPT_LAYER "`
+DB_PARAMS=`v.db.connect -g "$INMAP" fs='|' 2> /dev/null | grep "^$GIS_OPT_LAYER "`
if [ -n "$DB_PARAMS" ] ; then
- DB_TABLE=`echo "$DB_PARAMS" | cut -f2 -d' '`
- DB_KEY=`echo "$DB_PARAMS" | cut -f3 -d' '`
- DB_DATABASE=`echo "$DB_PARAMS" | cut -f4 -d' '`
- DB_DRIVER=`echo "$DB_PARAMS" | cut -f5 -d' '`
+ DB_TABLE=`echo "$DB_PARAMS" | cut -f2 -d'|'`
+ DB_KEY=`echo "$DB_PARAMS" | cut -f3 -d'|'`
+ DB_DATABASE=`echo "$DB_PARAMS" | cut -f4 -d'|'`
+ DB_DRIVER=`echo "$DB_PARAMS" | cut -f5 -d'|'`
db.copy from_driver="$DB_DRIVER" from_database="$DB_DATABASE" \
from_table="$DB_TABLE" to_table="tmp_vogb_epsg4326_$$"
Modified: grass/branches/releasebranch_6_4/scripts/v.rast.stats/v.rast.stats
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.rast.stats/v.rast.stats 2010-01-08 08:11:19 UTC (rev 40311)
+++ grass/branches/releasebranch_6_4/scripts/v.rast.stats/v.rast.stats 2010-01-08 08:31:26 UTC (rev 40312)
@@ -197,7 +197,8 @@
#check if DBF driver used, in this case cut to 10 chars col names:
DBFDRIVER=0
-v.db.connect -g "$VECTOR" fs=";" | grep -w "$GIS_OPT_LAYER" | cut -d';' -f5 | grep -i dbf --quiet
+v.db.connect -g "$VECTOR" fs=";" | grep -w "^$GIS_OPT_LAYER" | \
+ cut -d';' -f5 | grep -i dbf --quiet
if [ $? -eq 0 ] ; then
DBFDRIVER=1
else
@@ -209,7 +210,7 @@
DB_DATABASE="`v.db.connect -g "$VECTOR" fs=";" | cut -d';' -f4`"
#Find out which table is linked to the vector map on the given layer
-TABLE=`v.db.connect map="$VECTOR" -g fs=";" | grep -w "$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
+TABLE=`v.db.connect map="$VECTOR" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{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
Modified: grass/branches/releasebranch_6_4/scripts/v.report/v.report
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.report/v.report 2010-01-08 08:11:19 UTC (rev 40311)
+++ grass/branches/releasebranch_6_4/scripts/v.report/v.report 2010-01-08 08:31:26 UTC (rev 40312)
@@ -94,9 +94,9 @@
TMP3="`g.tempfile pid=$$`"
TMP4="`g.tempfile pid=$$`"
-MAP=$GIS_OPT_MAP
-OPTION=$GIS_OPT_OPTION
-LAYER=$GIS_OPT_LAYER
+MAP="$GIS_OPT_MAP"
+OPTION="$GIS_OPT_OPTION"
+LAYER="$GIS_OPT_LAYER"
# does the input vector map exist?
eval `g.findfile element=vector file=$GIS_OPT_MAP`
@@ -143,7 +143,7 @@
if [ $TABLEEXISTS -eq 1 ] ; then
v.db.select -c map="$MAP" layer="$LAYER" | sort -n -t'|' -k 1 | grep -v '^0' > "$TMP1"
if [ `wc -l "$TMP1" | awk '{print $1}'` -eq 0 ] ; then
- KEY=`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w "$LAYER" | cut -f3 -d';'`
+ KEY=`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w "^$LAYER" | cut -f3 -d';'`
g.message -e "There is a table connected to input vector map '$MAP', but\
there are no categories present in the key column '$KEY'. Consider using\
v.to.db to correct this."
More information about the grass-commit
mailing list