
# to be executed inline by scripts of STIC  

export start_dir
export stic_main_dir
export stic_bin_dir
export stic_scripts_dir


home_control_file=
start_dir=$(dirname "$0")
if test -n "$STIC_MAIN_DIR"
then
  dir=$STIC_MAIN_DIR
elif test -r $HOME/.stic_main_dir
then
  home_control_file=1
  dir=$(cat $HOME/.stic_main_dir)
else
  if test "$start_dir" = "." -o "$start_dir" = ""
  then
    dir=".."
  else
    dir=$(dirname "$start_dir")
  fi
fi

if test -e "$dir"/this_is_the_stic_main_directory
then
  stic_main_dir="$dir"/
  stic_bin_dir="$dir"/bin/
  stic_scripts_dir="$dir"/scripts/
elif test -n "$STIC_MAIN_DIR" -o -n "$home_control_file"
then
  stic_main_dir="$dir"/
  stic_bin_dir="$dir"/
  stic_scripts_dir="$dir"/
else 
  stic_main_dir="$start_dir"/
  stic_bin_dir="$start_dir"/
  stic_scripts_dir="$start_dir"/
fi

