#!/bin/sh

set -e

if [ -z "${1##-*}" ] && [ "$1" != -- ]; then
	exec touch.orig "$@"
fi

trap 'rm -f $TMP' EXIT
TMP=$(tempfile)

# Create the files if they don't exist.
touch.orig -a "$@"

tar -P --remove-files -cf $TMP "$@"
tar xfP $TMP
rm -f $TMP
exec touch.orig "$@"
