diff --git a/tools/iocsh.bash b/tools/iocsh.bash index 09b1ab0d8c73549fc3e3ab98c990bac7307f90df..1814d0676761c8bb0e59279959d90077991b5d23 100755 --- a/tools/iocsh.bash +++ b/tools/iocsh.bash @@ -58,12 +58,8 @@ declare -r TMP_PATH="/tmp/systemd-private-e3-iocsh-$(whoami)" # To get the absolute path where iocsh.bash is executed IOCSH_TOP=${PWD} -# Load any environment variables -if [ -f "$IOCSH_TOP/env.sh" ]; then - echo "Loading environment variables from $IOCSH_TOP/env.sh" - source "$IOCSH_TOP/env.sh" -fi - +# Load any environment variables, default is $IOCSH_TOP/env.sh +loadEnv "$@" BASECODE="$(basecode_generator)" diff --git a/tools/iocsh_functions b/tools/iocsh_functions index 7863b2bfd2e3635380fe533d033e6cfb6ea9533c..3a3df2e663382db2808fc7e128fd61ea9a872c9d 100644 --- a/tools/iocsh_functions +++ b/tools/iocsh_functions @@ -374,7 +374,26 @@ function check_mandatory_env_settings done }; +function loadEnv +{ + local envfile=$IOCSH_TOP/env.sh + while [ $# -gt 0 ]; do + + arg=$1 + case $arg in + ( -e ) + shift + envfile=$1 + ;; + esac + shift + done + if [ -f "$envfile" ]; then + echo "Loading environment variables from $envfile" + source "$envfile" + fi +} function loadFiles { @@ -438,6 +457,9 @@ function loadFiles ( -dv ) shift __LOADER__="valgrind --leak-check=full " + ;; + ( -e ) + shift ;; ( -* ) printf "Unknown option $1\n\n" >&2