#!/bin/sh
# $Id: rsync-mirror,v 1.10 2016/10/28 22:08:34 friedman Exp $

RSYNC_RSH=${RSYNC_RSH-rsh}
export RSYNC_RSH

case $* in
  *-quiet* ) : ;;
  *          ) set x --verbose ${1+"$@"} ; shift ;;
esac

case $* in
  *-inplace* ) : ;;
  *          ) set x --sparse ${1+"$@"} ; shift ;;
esac

case ${RS_UID-${UID-`id -u`}} in
  0 ) set x --devices   \
            ${1+"$@"}
      shift ;;
esac

set x \
	--owner		\
	--group		\
	--perms		\
	--times		\
			\
	--hard-links	\
	--links		\
			\
	--delete	\
	--force		\
			\
	--recursive	\
	${1+"$@"}
shift

if [ -t 0 ]; then
    ${RSYNC-rsync} -n ${1+"$@"} | sed -e 's/^/[PROPOSED] /'
    echo
    echo -n "Is this what you want (y/n)? "
    read resp
    case $resp in
        [Yy]* ) : ;;
        * ) exit 1 ;;
    esac
fi

exec ${RSYNC-rsync} ${1+"$@"}

# eof
