[GRASS-SVN] r59231 - grass/branches/develbranch_6/scripts/i.oif

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Mar 10 16:15:54 PDT 2014


Author: hamish
Date: 2014-03-10 16:15:54 -0700 (Mon, 10 Mar 2014)
New Revision: 59231

Modified:
   grass/branches/develbranch_6/scripts/i.oif/i.oifcalc
   grass/branches/develbranch_6/scripts/i.oif/m.cutmatrix
Log:
fix for WinGRASS: move temp filename out of awk, backslashes in the path were being treated as quoting chars; quote all variables

Modified: grass/branches/develbranch_6/scripts/i.oif/i.oifcalc
===================================================================
--- grass/branches/develbranch_6/scripts/i.oif/i.oifcalc	2014-03-10 22:14:29 UTC (rev 59230)
+++ grass/branches/develbranch_6/scripts/i.oif/i.oifcalc	2014-03-10 23:15:54 UTC (rev 59231)
@@ -10,7 +10,7 @@
     exit 1
 fi
 
-if [ $1 -lt 1 ] || [ $1 -gt 7 ] || [ $2 -lt 1 ] || [ $2 -gt 7 ] || [ $3 -lt 1 ] || [ $3 -gt 7 ] ; then
+if [ "$1" -lt 1 ] || [ "$1" -gt 7 ] || [ "$2" -lt 1 ] || [ "$2" -gt 7 ] || [ "$3" -lt 1 ] || [ "$3" -gt 7 ] ; then
     g.message -e "Invalid channel combination ($1 $2 $3)"
     exit 1
 fi
@@ -29,30 +29,30 @@
 export LC_NUMERIC
 
 # calculate SUM of Stddeviations:
-"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_stddev" 1 $1 >  "$temp_sum"
-"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_stddev" 1 $2 >> "$temp_sum"
-"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_stddev" 1 $3 >> "$temp_sum"
+"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_stddev" 1 "$1" >  "$temp_sum"
+"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_stddev" 1 "$2" >> "$temp_sum"
+"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_stddev" 1 "$3" >> "$temp_sum"
 
-cat "$temp_sum" | awk -v temp_file="$temp_calc" \
+cat "$temp_sum" | awk \
 'BEGIN {sum = 0.0} 
 NR == 1{}
 	{sum += $1 ; N++}
 END{
-print sum > temp_file
-}'
+print sum
+}' > "$temp_calc"
 
 # calculate SUM of absolute(Correlation values):
-"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_correlation" $1 $2 >  "$temp_sum"
-"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_correlation" $1 $3 >> "$temp_sum"
-"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_correlation" $2 $3 >> "$temp_sum"
+"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_correlation" "$1" "$2" >  "$temp_sum"
+"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_correlation" "$1" "$3" >> "$temp_sum"
+"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_correlation" "$2" "$3" >> "$temp_sum"
 
-cat "$temp_sum" | awk -v temp_file="$temp_calc" \
+cat "$temp_sum" | awk \
 'BEGIN {sum = 0.0}
 NR == 1{}
         {sum += sqrt($1*$1) ; N++}  # sqrt(x^2) is my ABS-function
 END{
-print sum >> temp_file
-}'
+print sum
+}' >> "$temp_calc"
 
 # Calculate OIF index:
 #     Divide (SUM of Stddeviations) and (SUM of Correlation)

Modified: grass/branches/develbranch_6/scripts/i.oif/m.cutmatrix
===================================================================
--- grass/branches/develbranch_6/scripts/i.oif/m.cutmatrix	2014-03-10 22:14:29 UTC (rev 59230)
+++ grass/branches/develbranch_6/scripts/i.oif/m.cutmatrix	2014-03-10 23:15:54 UTC (rev 59231)
@@ -16,9 +16,9 @@
     exit 1
 fi
 
-if [ $2 -lt 1 ] || [ $3 -lt 1 ] ; then
+if [ "$2" -lt 1 ] || [ "$3" -lt 1 ] ; then
     echo "xpos ($2) and ypos ($3) must be positive integers"
     exit 1
 fi
 
-cat "$1" | tail -n 7 | cut -f $2 -d ' ' | head -n $3 | tail -n 1
+cat "$1" | tail -n 7 | cut -f "$2" -d ' ' | head -n "$3" | tail -n 1



More information about the grass-commit mailing list