#!/bin/ksh
#
# $Id: nsrrcopy.sh,v 1.5 2007/05/07 14:52:21 gsachar Exp $ Copyright (c) 2005-2007, EMC Corporation.
#

#
# Copyright (c) 2005-2007 EMC Corporation.
#
# All rights reserved.  This is an UNPUBLISHED work, and
# comprises proprietary and confidential information of EMC.
# Unauthorized use, disclosure, and distribution are strictly
# prohibited.  Use, duplication, or disclosure of the software
# and documentation by the U.S. Government is subject to
# restrictions set forth in a license agreement between the
# Government and EMC or other written agreement specifying
# the Government's rights to use the software and any applicable
# FAR provisions, such as FAR 52.227-19.
#

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/etc:/usr/opt/networker/bin:/opt/networker/bin; export PATH

# get the path of this script, so we can run uasm from there

set_path=`dirname $0`

# If the savestream passed to this script on the standard input stream was 
# created relative to a directory i.e. (uasm -s -u -v .), the user may want
# to recover the savestream relative to a different base directory.  This
# is done via the -t option. 
#
# If the savestream passed to this script on the standard input stream was
# created with an absolute path i.e. (uasm -s -u -v c:\tmp), then the -t
# option will have no impact.
# 

if [ "$1" = "-t" ]
then
    if [ ! -d "$2" ] || [ ! -w "$2" ]
    then
 	mkdir $2
    fi
    cd $2
    shift
    shift
else
    cd $set_path
fi

# Check if the path mapping option (-m) was specified by the caller. If so,
# the uasm command is adjusted to perform the substitution specified by the 
# following two arguments.
#

if [ "$1" = "-m" ]
then
    $set_path/uasm -r -iY -m $2=$3 $4 1>&2 2>>/tmp/uasm.log
else
    $set_path/uasm -r -iY $1 1>&2 2>>/tmp/uasm.log
fi

exit $?
