[GRASS-dev] [bug #5499] (grass) bash scripts starting with #!/bin/sh

Maciek Sieczka via RT grass-bugs at intevation.de
Sun Mar 18 07:51:51 EDT 2007


Another bunch of possible bashism, in regard too Hamish'es hints on how to
avoid them.

Hamish wrote:
> use "=" not "==" for string compares

These do not conform:

d.correlate:  if [ "$name" == "" ] ; then
d.correlate:if [ "$ok" == "no" ] ; then
d.polar:if [ $TOTALVALIDNUMBER == 0 ] ; then
d.vect.thematic:    if [ "`db.columns table=$table database=$database
driver=$driver| grep -i grassrgb`" == "" ] ; then
g.mlist:  if [ "$itype" == "all" ] ; then
r.fillnulls:r.mapcalc "MASK=if($TMP1.buf==2,1,null())"
r.plane:         if (dist==0) {
r.plane:        if (typeflag==""){
v.rast.stats: r.mapcalc "MASK=if(${VECTOR}_${TMPNAME} == $i, 1, null())" 2>
/dev/null

Also, I guess (and only guess) that -+ and += would fail for non-Bash. There
are some in r.tileset:

r.tileset:      for ((min_i=0;min_i<min_n;min_i+=1)) ; do
r.tileset:      for ((max_i=0;max_i<max_n;max_i+=1)) ; do
r.tileset:      for ((pp_i=0;pp_i<pp_max;pp_i+=2)) ; do
r.tileset:      for ((sl_i=0;sl_i<sl_max;sl_i+=2)) ; do
r.tileset:for ((xi=0;xi<ximax;xi+=1)); do
r.tileset:      for ((yi=0;yi<yimax;yi+=1)); do

Should min_i+=1 be replaced with `expr $min_i + 1` etc.?

Maciek


-------------------------------------------- Managed by Request Tracker




More information about the grass-dev mailing list