#!/bin/bash
set -u

# Try to get the correct version of the 'p4p' server.
# If we cannot detect it, abort, as it could be
# dangerous if we select the wrong one.

if [[ -n "${SDP_INSTANCE:-}" && -n "${P4HOME:-}" ]]; then
   exec "${P4HOME}/bin/p4p_${SDP_INSTANCE}" "$@"
   exit $?
else
   echo -e "\\nError: The SDP shell environment is not setup. The correct version of p4p cannot be determined."
   exit 1
fi