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

Daniel Calvelo dca.gis at gmail.com
Mon Mar 19 18:22:45 EDT 2007


Ok, I've changed d.correlate, d.polar, d.vect.thematic and g.mlist.
The other hits were either awk, r.mapcalc, or r.tileset :)

BTW there are lots of 'if test "$GISBASE" = ""; then' ; was this a
preferred method to -z for some reason? Is there some risk involved?

Daniel.

On 3/18/07, Hamish <hamish_nospam at yahoo.com> wrote:
> [this matters as the new Ubuntu uses [d]ash for #!/bin/sh not bash]
>
> Maciek Sieczka via RT wrote:
> > Another bunch of possible bashism, in regard too Hamish'es hints on
> > how to avoid them.
>
> (as collected from this list mostly)
>
> > Hamish wrote:
> > > use "=" not "==" for string compares
> >
> > These do not conform:
> >
> > d.correlate:  if [ "$name" == "" ] ; then
>
> # use -z to test if string is zero-length, -n to test if non-zero length
> if [ -z "$name" ] ; then
>
> > d.correlate:if [ "$ok" == "no" ] ; then
>
> # only use a single "=" for string compares
> if [ "$ok" = "no" ] ; then
>
> > d.polar:if [ $TOTALVALIDNUMBER == 0 ] ; then
>
> # use -eq integer compare
> if [ "$TOTALVALIDNUMBER" -eq 0 ] ; then
>
> > d.vect.thematic:    if [ "`db.columns table=$table database=$database
> >   driver=$driver | grep -i grassrgb`" == "" ] ; then
>
> Use -z. Note d.vect.thematic also uses "let" in a several places which
> needs to be changed to `expr`.
>
> > g.mlist:  if [ "$itype" == "all" ] ; then
>
> =
>
> > r.fillnulls:r.mapcalc "MASK=if($TMP1.buf==2,1,null())"
>
> "==" is ok within a r.mapcalc expression. Not a bug.
>
> > r.plane:         if (dist==0) {
>
> -eq
>
> > r.plane:        if (typeflag==""){
>
> -z
>
> > v.rast.stats: r.mapcalc "MASK=if(${VECTOR}_${TMPNAME} == $i, 1,
> > null())" 2> /dev/null
>
> ok within r.mapcalc. Not a bug.
>
>
> > Also, I guess (and only guess) that -+ and += would fail for non-Bash.
> > There are some in r.tileset:
>
> As Glynn already noted, r.tileset is written as a bash program, not a
> unix shell script, and it is more work than I want to undertake to
> rewrite it.
>
>
>
> Hamish
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass-dev
>


-- 
-- Daniel Calvelo Aros




More information about the grass-dev mailing list