#! /bin/sh

#-------------------------------------------------------------------------------
# Recursively call other plug-ins that have same name as issuer.
# All shell parameters are passed to called plug-ins.
#-------------------------------------------------------------------------------
call_plugins() {
  RECURSE_COMMAND=`basename "$0"`
  [ -z "${RECURSE_COMMAND}" ] && return

  MY_BINDIR=`dirname "$0"`
  MY_PLUGIN=`cd "${MY_BINDIR}"; cd ..; pwd`

  __call_plugins_exit_code="0"
  for dir in "${EF_ROOT}"/plugins/*
  do
    if [ "$dir" != "${MY_PLUGIN}" ]
    then
      if [ -f "${dir}/bin/${RECURSE_COMMAND}" -a -x "${dir}/bin/${RECURSE_COMMAND}" ]
      then
        "${dir}/bin/${RECURSE_COMMAND}" "$@"
        if [ $? -ne 0 ]
        then
          __call_plugins_exit_code="1"
        fi
      fi
    fi
  done
  return ${__call_plugins_exit_code}
}
