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

Hamish hamish_nospam at yahoo.com
Mon Feb 26 22:42:52 EST 2007


Glynn Clements wrote:
> 
> Hamish wrote:
> 
> > 2) keep #!/bin/sh, but add this within the script:
> > 
> > if [ -z "$BASH" ] ; then
> >    echo "$0: This script requires Bash." 1>&2
> >    exit 1
> > fi
> 
> Or:
> 	if [ -z "$BASH" ] ; then
> 	    exec bash "$0" "$@"
> 	    echo "$0: This script requires Bash." 1>&2
> 	    exit 1
> 	fi
> 
> AFAICT, that should work so long as bash is called "bash" (and not
> e.g. "bash2" or "bash-3.1.17") and is somewhere in the path.


should we worry about the case where bash has been symlinked to ash
and the thing loops?


As long as it works with mac,cygwin,90% linuxes, I'm still leaning
towards simply changing the shebang to #!/bin/bash. I am happy to assume
BSD,IRIX,AIX,fringe linux folks will be capable enough to modify it
themselves if that's needed.


Hamish




More information about the grass-dev mailing list