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

Glynn Clements glynn at gclements.plus.com
Sun Feb 18 19:35:04 EST 2007


Maciek Sieczka via RT wrote:

> AFAIK, GRASS shell scripts are supposed to work with any POSIX 1003.2
> compliant sh interpreter. Apparently some still don't, eg. r.tileset and
> r.in.wms as we can see.
> 
> As the bash->dash switch in Ubuntu 6.1 seems inrevertable (see:
> https://launchpad.net/ubuntu/+source/dash/+bug/61463, the comment by Matthew
> Garrett at 2006-11-29 05:23:16 UTC, in particular), and it looks justified
> from technical point of view,

Note that NetBSD has always used "ash" as its /bin/sh, as do a number
of embedded Linux distributions. Also, most commercial Unices use
something other than bash as their /bin/sh.

In general, assuming /bin/sh == bash is a bad idea.

> we have 3 options it seems:
> 
> 1. Have (some) GRASS sh scripts broken for Ubuntu (what if other distros
> follow Ubuntu?). What with platforms not providing bash?

The only sensible option, IMHO.

> 2. Revise all the scripts and fix all bashisms; buts:
> - who would do it?
> - it takes quite some knowledge to decide what needs to be fixed, and it could
> take much time
> - what with the addons? remove all that are not POSIX-compliant? fix them
> ourselves? Anyway, much work.

Change them to #!/usr/local/bin/bash. Users who have bash will have to
change the path; users who don't have bash will at least get a
reasonably straightforward error message, e.g.:

	/usr/local/bin/bash: bad interpreter: No such file or directory

rather than obscure problems with the script (or, worse still, no
error but bogus results).

Either way, most users will have an incentive to either fix the script
or at least provide us with a continual stream of reminders that our
scripts are broken.

> 3. Change all GRASS sh scripts to require #/bin/bash. Least work. But what
> with platforms not providing bash?

Or not installing it in /bin (i.e. probably anything where bash isn't
the primary shell, e.g. most commercial Unices).

Note that /bin (and /sbin, /lib etc) are meant for programs which need
to work when /usr doesn't exist (e.g. if /usr is on NFS, anything
which is required to configure and enable networking can't go under
/usr). If bash isn't a core part of the OS (i.e. it isn't /bin/sh),
there's a good chance that it won't be in /bin.

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




More information about the grass-dev mailing list