###########################################################################
#
# Set up GILDAS environment under bash (J.Pety 2023).
#
###########################################################################
#
GAG_GAG="${HOME}/.gag"
#
if [ "$GAG_EXEC_DIR" != "" ]; then
    # Undo append operations done by previous call. Beware not to leave a leading column
    PATH=`echo $PATH | sed "s%${GAG_EXEC_DIR}/bin:*%%"`
    LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH | sed "s%${GAG_EXEC_DIR}/lib:/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib:/opt/local/lib:*%%"`
    PYTHONPATH=`echo $PYTHONPATH | sed "s%${GAG_EXEC_DIR}/python:*%%"`
fi
#
GAG_EXEC_DIR="${GAG_ROOT_DIR}/${GAG_EXEC_SYSTEM}"
#
GAG_PATH="${GAG_ROOT_DIR}/etc"
if [ "$PATH" = "" ]; then
    PATH="${GAG_EXEC_DIR}/bin"
else
    PATH="${GAG_EXEC_DIR}/bin:${PATH}"
fi
if [ "$LD_LIBRARY_PATH" = "" ]; then
    LD_LIBRARY_PATH="${GAG_EXEC_DIR}/lib:/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib:/opt/local/lib"
else
    LD_LIBRARY_PATH="${GAG_EXEC_DIR}/lib:/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib:/opt/local/lib:${LD_LIBRARY_PATH}"
fi
if [ "$PYTHONPATH" = "" ]; then
    PYTHONPATH="${GAG_EXEC_DIR}/python"
else
    PYTHONPATH="${GAG_EXEC_DIR}/python:${PYTHONPATH}"
fi
if [ "$GDK_RENDERING" = "" ]; then
  true
fi
export PATH GAG_GAG GAG_PATH LD_LIBRARY_PATH PYTHONPATH GAG_ROOT_DIR GAG_EXEC_DIR
if [ -n "$PS1" ]; then
    echo
    echo "Selecting GILDAS version: jan26a (01jan26 05:00 cet), executable tree, ${GAG_EXEC_SYSTEM}"
    echo
fi
#
###########################################################################
