#!/bin/csh
#	@(#)updateapp	1.2	08/14/95
#
#
#     $Id: updateapp,v 1.1 1998/03/16 20:03:02 avvede Exp $
#     $Log: updateapp,v $
#     Revision 1.1  1998/03/16 20:03:02  avvede
#     Initial move to CVS
#
#
#
#
#	Copyright (c) 1986, 1987, 1988 by
#	Periphonics Corporation
#	4000 Veterans Memorial Highway
#	Bohemia
#	NY 11716
#
#	This software is furnished under a license and may be used and
#	copied only in accordance with the terms of such license and with
#	the inclusion of the above copyright notice. This software or any
#	other copies thereof, may not be provided or otherwise made available
#	to anyone other than the licensee. Title to and ownership of this
#	software remains with the Periphonics Corporation.
#
#	The information in this document is subject to change without notice
#	and should not be construed as a commitment by Periphonics.
#
#	Periphonics assumes no responsibility for the use or reliability of
#	its software on equipment that is not supplied by Periphonics.
#
#	File Name:
#		updateapp
#
#	Description:
#		Procedure to update existing application ( *vex )
#		See usage line below.
#
#	Change				Reason
#	No.	Date		Name	for Change
#
#	0	09-aug-95	lmg	Originated.
#	1	14-aug-95	lmg	Removed 'vex' from amu message.
#
if ( ${?ASEHOME} == 0 ) then
	if ( ${?VASHOME} == 0 ) then
		setenv ASEHOME /usr/ase
	else
		setenv ASEHOME $VASHOME
	endif
endif
#
#	set up command name
#
if ($?0 == 0) then
	set cmd=updateapp
else
	set cmd=$0
endif
if ($#argv != 2) then
usage:
	echo "usage: $cmd source-file target-file"
	exit 1
endif
unalias cd
unalias rm
unalias mv
unalias cp
#
# Set args
#
	set source = $1
	set ext = $1:e
	if ( "$ext" != "vex" ) then
		set source = "$source".vex
		if ( ! -f $source ) then
			echo "Cannot access the file $source"
			exit 1
		endif
	endif

	set target = $2
	set ext = $2:e
	if ( "$ext" != "vex" ) then
		set target = "$target".vex
	endif
#
# 	First of all we need to know
# 	the full path to check existence of all files
#
	set libpath=`dirname $target`		# directory path, may be with '.'
	set curdir=$cwd
	cd $libpath
	set fullpath=$cwd
	cd $curdir
	set fullapp="$fullpath"/"$target:t"	# make a full appname with abs path (needed for AMU)
#
# Save a target file, signal to applications and remove the target
#
	if ( -f $target ) then
		mv $target "$target".
		"rm" "$target".
	endif
#
# Update the target
#
	cp $source $target
	amu -c "p b request location close $fullapp:r" > /dev/null &
	exit 0
