Problem 1306

Summary: geant4.sh crashes when run with dash instead of bash (as in Ubuntu systems from .profile)
Product: Geant4 Reporter: S Barnes <sbarnes>
Component: cmakeAssignee: Ben Morgan <Ben.Morgan>
Status: CLOSED FIXED    
Severity: normal CC: sbarnes
Priority: P5    
Version: 9.5   
Hardware: All   
OS: Linux   

Description S Barnes 2012-04-20 00:17:23 CEST
Geant 4.9.5.p01
Ubuntu 11.10

To replicate run:

$dash /path/to/geant4/bin/geant4.sh

which should return the following error

/path/to/geant4/bin/geant4.sh: 30: Bad substitution

The root problem is the check to see if you are running bash or not (line 20):

if [ "x${BASH_ARGV[0]}" = "x" ]; then

Since array variables are not POSIX complaint the check to see if we are in bash will cause non-bash shells (specifically dash) to fail. The fix is simple replace the above line with:

if [ -z "$BASH_VERSION" ]; then

This is a much better way to see if we are running bash. The cmake file that needs patching is Geant4ToolchainBackwardCompatibility.cmake line 84. 

This is a concern because all Ubuntu systems (since version 6) use dash instead of bash during boot and login. So if you put the following line in your '.profile' file

. /path/to/geant4/bin/geant4.sh > /dev/null

In order to setup the environment variables for Geant4 as the installation guide recommends, the script will crash and you cannot login.
Comment 1 Ben Morgan 2012-04-20 20:26:47 CEST
Fixed in tag cmake-V09-05-13.