1
by brian
clean slate |
1 |
# WARNING -- first line intentionally left blank for sh/csh/ksh
|
2 |
# compatibility. Do not remove it! FNF, UniSoft Systems.
|
|
3 |
#
|
|
4 |
# Usage is:
|
|
5 |
# install <from> <to>
|
|
6 |
#
|
|
7 |
# The file <to> is replaced with the file <from>, after first
|
|
8 |
# moving <to> to a backup file. The backup file name is created
|
|
9 |
# by prepending the filename (after removing any leading pathname
|
|
10 |
# components) with "OLD".
|
|
11 |
#
|
|
12 |
# This script is currently not real robust in the face of signals
|
|
13 |
# or permission problems. It also does not do (by intention) all
|
|
14 |
# the things that the System V or BSD install scripts try to do
|
|
15 |
#
|
|
16 |
||
17 |
if [ $# -ne 2 ] |
|
18 |
then
|
|
19 |
echo "usage: $0 <from> <to>" |
|
20 |
exit 1 |
|
21 |
fi
|
|
22 |
||
23 |
# Now extract the dirname and basename components. Unfortunately, BSD does
|
|
24 |
# not have dirname, so we do it the hard way.
|
|
25 |
||
26 |
fd=`expr $1'/' : '\(/\)[^/]*/$' \| $1'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \| .` |
|
27 |
ff=`basename $1` |
|
28 |
td=`expr $2'/' : '\(/\)[^/]*/$' \| $2'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \| .` |
|
29 |
tf=`basename $2` |
|
30 |
||
31 |
# Now test to make sure that they are not the same files.
|
|
32 |
||
33 |
if [ $fd/$ff = $td/$tf ] |
|
34 |
then
|
|
35 |
echo "install: input and output are same files" |
|
36 |
exit 2 |
|
37 |
fi
|
|
38 |
||
39 |
# Save a copy of the "to" file as a backup.
|
|
40 |
||
41 |
if test -f $td/$tf |
|
42 |
then
|
|
43 |
if test -f $td/OLD$tf |
|
44 |
then
|
|
45 |
rm -f $td/OLD$tf |
|
46 |
fi
|
|
47 |
mv $td/$tf $td/OLD$tf |
|
48 |
if [ $? != 0 ] |
|
49 |
then
|
|
50 |
exit 3 |
|
51 |
fi
|
|
52 |
fi
|
|
53 |
||
54 |
# Now do the copy and return appropriate status
|
|
55 |
||
56 |
cp $fd/$ff $td/$tf |
|
57 |
if [ $? != 0 ] |
|
58 |
then
|
|
59 |
exit 4 |
|
60 |
else
|
|
61 |
exit 0 |
|
62 |
fi
|
|
63 |
||
64 |