#!/bin/sh
#set -x
if [ "$1" = "-v" ];then
  v=v
  shift
else
  v=
fi
# Attempt to detect if copying from an ISO: specify --atime-preserve if not
df .|grep 100% >/dev/null 2>&1 && a="" || a=--atime-preserve
if [ -z "$1" -o -z "$2" ];then
  echo 'Usage:-' $0 '[-v] <path> <target-dir>'
  exit 1
fi
if [ ! -d "$2" ];then
  echo "$2 is not a directory"
  exit 1
fi
if [ ! \( -d "$1" -o -f "$1" \) ];then
  echo "$1 is neither a file nor a directory"
  exit 1
fi
tar -cf - $a "$1" | tar -C "$2" -x${v}pUf -
