#!/bin/bash

find_python () {
  # find the path to a valid python interpreter
  if command -v python3 >/dev/null 2>&1; then
    command -v python3
  elif command -v python >/dev/null 2>&1; then
    command -v python
  elif command -v python2 >/dev/null 2>&1; then
    command -v python2
  else
    echo "no python interpreter found; you must install python" >&2
    exit 1
  fi
}

# this MUST exec to avoid putting a bash process into the process tree between
# TCL and python in the 'globusconnect.tcl' context
exec "$(find_python)" "$@"
