#!/bin/sh
# -*- perl -*-
#
# (c) Copyright 1999-2014, Riverbed Technology, Inc. All rights reserved.
#
# ----------------------------------------------------------
# perl/miniperl

if [ ! -d "$ZEUSHOME/zxtm" -a ! -d "$ZEUSHOME/web" ]
then
   DIRNAME=`dirname $_`
   if [ "$DIRNAME" = "" ]
   then
      exec perl/miniperl-pre7 "$@"
   else
      exec $DIRNAME/miniperl-pre7 "$@"
   fi
fi

if [ -d "$ZEUSHOME/zxtm" ]
then
   PERL_VERSION=`$ZEUSHOME/perl/miniperl-pre7 -e 'my $tmp = readlink( "$ENV{ZEUSHOME}/zxtm" ); $tmp =~ s/zxtm-//; print "$tmp\n";'`
else if [ -d "$ZEUSHOME/web" ]
then
   PERL_VERSION=`$ZEUSHOME/perl/miniperl-pre7 -e 'my $tmp = readlink( "$ENV{ZEUSHOME}/web" ); $tmp =~ s/web-//; print "$tmp\n";'`
fi
fi


if [ -x "$ZEUSHOME/perl/miniperl-$PERL_VERSION" ]
then
   exec $ZEUSHOME/perl/miniperl-${PERL_VERSION} "$@"
fi

exec $ZEUSHOME/perl/miniperl-pre7 "$@"
