Problem 1306 - geant4.sh crashes when run with dash instead of bash (as in Ubuntu systems from .profile)
Summary: geant4.sh crashes when run with dash instead of bash (as in Ubuntu systems fr...
Status: CLOSED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: cmake (show other problems)
Version: 9.5
Hardware: All Linux
: P5 normal
Assignee: Ben Morgan
URL:
Depends on:
Blocks:
 
Reported: 2012-04-20 00:17 CEST by S Barnes
Modified: 2018-05-08 14:48 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
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.