#!/bin/sh

# SPDX-FileCopyrightText: 2009 Fermi Research Alliance, LLC
# SPDX-License-Identifier: Apache-2.0

# Description:
#   This is a shell script wrapper for pychirp.py


if [ -f "$1" ]; then
    glidein_config="$1"
    # retained grep here since (1) it is being used to get the value of EEROR_GEN_PATH only, i.e. single occurrence, and (2) the variable is safe meaning not modified by the scripts
    error_gen=$(grep '^ERROR_GEN_PATH ' "$glidein_config" | awk '{print $2}')
fi

[ -n "$error_gen" ] && CONFIG=TRUE

if [ -n "$CONFIG" ]; then
    "$error_gen" -ok "libtest.sh" "WN_Resource" "pychirp wrapper"
else
    exec "$(dirname "$0")"/gwms-python -m htchirp "$@"
    echo "$0: failed to execute the python condor_chirp" >&2
    exit 1
fi
