#!/usr/bin/env pkgcore-ebuild-helper

check_args 1 -

pattern="s:${ED}::g"

for x in "$@"; do
	trg=${ED}/${x}
	if [[ ! -e ${trg} ]]; then
		pattern=${x}
		continue
	fi
	if [[ ! -f ${trg} ]]; then
		error "'${trg}' is not a regular file!";
		continue
	fi
	tmp_file=${T}/${trg##*/}
	if check_command cp "${trg}" "${tmp_file}"; then
		check_command sed -e "${pattern}" "${tmp_file}" > "${trg}"
		rm -f "${tmp_file}"
	fi
done
