[GRASS-dev] Re: 'g.gui wxpython' won't work in wingrass as wxgui is a shell script

Ivan Shmakov ivan at theory.asu.ru
Wed Mar 5 03:24:12 EST 2008

>>>>> Hamish  <hamish_b at yahoo.com> writes:

 >>> FWIW all known bashisms were removed prior to GRASS 6.2.2.

 > ...

 >>> Anything left needing bash explicitly uses #!/bin/bash

 >> I. e., `i.spectral', `r.mapcalculator', `r.tileset' and
 >> `v.in.gps.babel'?  Could someone please point me to the list of the
 >> identified Shell portability issues of these scripts?

 > $ grep -rI 'bin/bash' scripts/* | cut -f1 -d: | grep -v '/.svn/'

	BTW, you can use `-l' instead of `cut', e. g.:

   $ grep -rlI 'bin/bash' scripts/* | grep -v '/.svn/' 

 > scripts/i.spectral/i.spectral

 > variable arrays are bash specific: ${COORD[$i]}

 > I am not sure if this is ok or not: $( cat "$TMP1") ?

	Completely.  See, e. g.:


	Furthermore, I'd recommend the $(...) form for all the new code.

 > scripts/r.tileset/r.tileset: heavy use of variable arrays

 > scripts/v.in.gpsbabel/v.in.gpsbabel: not sure maybe mentioned in the
 > bashism threads in the archives?

	It seems that was because of `echo -e' [1] which seems to have
	been subsequently removed.  The `checkbashisms' script shows
	nothing for `v.in.gpsbabel' now.

[1] nntp://news.gmane.org/gmane.comp.gis.grass.devel/19389

	It was noted that `echo' is generally ``unsafe''.  Consider,
	e. g., the following code:

echo "$a"

	Contrary to the expectations, this code /doesn't/ print the
	value of the `a' variable in all the possible cases.  E. g.:

$ echo "$a" 
$ printf "a: %s\n" "$a"
a: -n

	(And it gets even worse if the `echo' command is extended to
	support `-e' as well.)

	Fortunately, the only case when this ``feature'' may be
	effective is the `echo "$..." ...' case.

 > ISTR that dash had an option to bulk test a script for bashisms.
 > (see the archives)


 > I don't know if it is worth the effort to worry about making those sh
 > compatible. Even on Ubuntu where !/bin/sh isn't Bash, Bash is still
 > there from the terminal prompt and if you request it in the shebang.
 > And we've had no complaints from embedded users.  v.in.gpsbabel and
 > r.tileset should both be rewritten in another language anyway
 > (python) so spending lots of effort on the current versions of them
 > would be energy better spent somewhere else IMO.


 > what's wrong with r.mapcalculator?

	Nothing.  It was my mistake.


 > See also GRASS's tcltk gronsole capability* & QGIS's python shell
 > menu item.

 > [*] try typing 'ls' and then click [Run], or 'xeyes' and then [Run
 > (bg)] in the lower panel of GIS.m's ouput window. I guess we could
 > put some text like "console:" above the lower frame.

	Unfortunately, it won't allow one to ``[Run]'' `for i in 1 2 3 ;
	do something ; done' if there'd be no Shell.

More information about the grass-dev mailing list