set -euo pipefail
if ! command -v file >/dev/null 2>&1; then
echo "file binary not found in PATH" >&2
exit 1
fi
if ! command -v stash >/dev/null 2>&1; then
echo "stash binary not found in PATH" >&2
exit 1
fi
id="$(stash push --print=stdout "$@")"
data_path="$(stash path "${id}")"
type="$(file -b --mime-type "${data_path}")"
stash attr "${id}" "type=${type}" >/dev/null
printf '%s\n' "${id}"