[GRASS-dev] Re: grass-dev Digest, Vol 10, Issue 46

Glynn Clements glynn at gclements.plus.com
Tue Feb 20 12:07:13 EST 2007


Hamish wrote:

> but the r.tileset script makes Heavy use of SIZE_ARRAY[0]="" style
> Bash arrays, so I fear it will need to be totally rewritten or
> declared "Bash only".  Is this enough for such a test?
> 
> if [ "`basename $SHELL`" != "bash" ] ; then
>    echo "$0: This script requires Bash" 2>&1
>    exit 1
> fi
> 
> (apparently not, starting ash from the bash prompt preserved $SHELL
> as /bin/bash; but maybe it helps catch real world cases?

No. $SHELL contains the user's preferred interactive shell; it is set
on login from the last field in the user's entry in /etc/passwd, and
won't normally change thereafter.

It is used mainly by programs which provide an option to spawn an
interactive shell (a feature which goes back to a time when many
Unices didn't provide job control, so you couldn't just use Ctrl-Z to
suspend the program).

> I guess the real issue is testing what the /bin/sh symlink points
> to. I guess Init.sh could run a little test and set
> GRASS_HAVE_BASH=1, but it is better to just fix r.tileset)

There's no guarantee that /bin/sh is a symlink. A more reliable test
is to check $BASH or $BASH_VERSION.

> > Run it under a less "enhanced" shell such as ash or dash.
> > 
> > I suspect that this may be the "real" motivation for using dash for
> > /bin/sh on Ubuntu. Using bash as /bin/sh is asking for people to write
> > bash-specific scripts (and putting #!/bin/sh at the top of them).
> 
> see  https://wiki.ubuntu.com/DashAsBinSh

You shouldn't believe everything you read on the web ;)

I'm aware that the stated reason is for speed, but I wouldn't expect
them to do such a thing with the stated intention of breaking stuff. 

Not only would there be many people who would favour the quick fix of
going back to bash, but the ones in that camp are likely to be the
hardest to try to reason with; i.e. a combination of impatient "make
it work now" types, delusional "it's not really a problem" types, and
the "my scripts are broken but I'd prefer to claim it's your fault"
types).

OTOH, it could just be for speed; you can never be sure about other
people's motivations (and you can't necessarily be sure of your own).

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list