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