#!/bin/sh set -ef __template_list=$(mktemp) find "$@" -follow -name '*.in' -type f -printf '%p\0' \ | sort -zuV > "${__template_list}" [ -s "${__template_list}" ] || { rm -f "${__template_list}" exit } __have_args="${ENVSUBST_ARGS:+1}" if [ -z "${__have_args}" ] ; then ## optimize envsubst-single invocation by caching argument list ## ref: envsubst-single ENVSUBST_ARGS=$(mktemp) envsubst-args.sh > "${ENVSUBST_ARGS}" export ENVSUBST_ARGS fi set +e ; __ret=0 xargs -0r -n 1000 -a "${__template_list}" \ envsubst-multi < /dev/null || __ret=1 [ -n "${__have_args}" ] || rm -f "${ENVSUBST_ARGS}" rm -f "${__template_list}" exit ${__ret}