#! /bin/sh
## This Bourne-shell script is used to initialize and run Ferret using 
## the pyferret Python module.  The intent of this script is to provide 
## a traditional Ferret interface through the pyferret module.

## set python_exe to the (optionally full-path) python executable to use
python_exe=python3

##
## ==== The following should not need any modifications ====
##

## The pyferret assignment to PYTHONPATH and LD_LIBRARY_PATH 
## is now done in the ferret_paths script.

## Finally, execute an in-line Python script to run Ferret using the pyferret 
## module.  The init method explicity processes the $PYTHONSTARTUP file, if it
## exists and if '-secure' was not given as a command-line argument.
if echo "$@" | grep -q -- "-linebuffer"; then
    GFORTRAN_UNBUFFERED_PRECONNECTED=1
    export GFORTRAN_UNBUFFERED_PRECONNECTED
    python_flags="-u -i"
else
    python_flags="-i"
fi
${python_exe} ${python_flags} -c "import sys; import pyferret; (errval, errmsg) = pyferret.init(sys.argv[1:], True)" "$@"

