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

Glynn Clements glynn at gclements.plus.com
Sun Feb 18 18:36:15 EST 2007


Request Tracker wrote:

> this bug's URL: http://intevation.de/rt/webrt?serial_num=5499
> -------------------------------------------------------------------------
> 
> Subject: bash scripts starting with #!/bin/sh
> 
> Platform: GNU/Linux/x86
> grass obtained from: Other (CDROM etc)
> grass binary for platform: Downloaded precompiled Binaries
> GRASS Version: 6.2.1
> 
> I experienced problems with Ubuntu 6.10 installation. The r.in.wms script refused to work with errors like this:
> /usr/lib/grass/etc/r.in.wms//wms.request: 326: SIZE_ARRAY[0]=: not found
> /usr/lib/grass/scripts/r.tileset: 193: declare: not found
> /usr/lib/grass/scripts/r.tileset: 258: Syntax error: Bad for loop variable
> 
> It took me about a couple of hours to find out that the reason is that
> Ubuntu developers decided to change the symbolic link /bin/sh from
> /bin/bash to /bin/dash, which is POSIX-compliant, but much less
> feature-rich than bash.
> 
> Setting it back to /bin/bash solved the problem, but still indicating
> the right interpreter in the headers will also be great.

The problem is that you can't rely upon bash being installed in a
specific location[1]. On Linux, it's the "primary" shell, so it's
/bin. On Unices which include it as an "extra", it's likely to be in
/usr/bin. If it isn't part of the core OS, it could be anywhere,
although /usr/local/bin, /sw/bin and /opt/sw/bin are all plausible.

[1] Actually, you can't rely upon bash being installed at all. GRASS
isn't specifically a Linux package; at least, it isn't supposed to be.

The only thing which you can absolutely rely upon is that /bin/sh will
be a POSIX-compatible Bourne shell. Anyone writing scripts would do
well to bear this in mind (IOW, please avoid using bash-specific
features).

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




More information about the grass-dev mailing list