#!/bin/bash

sourced=0
if [ -n "$ZSH_EVAL_CONTEXT" ]; then
  case $ZSH_EVAL_CONTEXT in *:file) sourced=1;; esac
elif [ -n "$KSH_VERSION" ]; then
  [ "$(cd $(dirname -- $0) && pwd -P)/$(basename -- $0)" != "$(cd $(dirname -- ${.sh.file}) && pwd -P)/$(basename -- ${.sh.file})" ] && sourced=1
elif [ -n "$BASH_VERSION" ]; then
  (return 0 2>/dev/null) && sourced=1
else # All other shells: examine $0 for known shell binary filenames
  # Detects `sh` and `dash`; add additional shell filenames as needed.
  case ${0##*/} in sh|dash) sourced=1;; esac
fi
[[ "$sourced" = 0 ]] && echo "Error: Must source this script. Run 'source balsamdeactivate' instead of 'balsamdeactivate'" && exit

if [ ! -z "$OLD_PS1" ]
then
    export PS1=$OLD_PS1
    unset OLD_PS1
fi

if [ ! -z "$BALSAM_DB_PATH" ]
then
    unset BALSAM_DB_PATH
    return 0
else
    echo "No Balsam DB is currently active"
    return 1
fi
