#!/usr/bin/env bash
# xargs --max-procs compatible command wrapper
# if given command fails, return 255 to stop xargs processing
#
# from xargs man page:
#     If any invocation of the command exits with a status of 255,
#       xargs will stop immediately without reading any further input.

$*

ret_code=$?

if [ "${ret_code}" != 0 ] ; then
  echo "Exit code: ${ret_code}. Command failed: $*" 1>&2
  exit 255
fi
