Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#!/bin/sh
2
# $Id: instcopy,v 1.3 2002/02/21 22:24:53 giles Exp $
3
#
4
# Implement a uniform 'install' syntax independent of which of the two
5
# "standard" install programs is installed.  Based on ideas in, but not
6
# copied from, the GNU fileutils install-sh script.  Usage:
7
#	instcopy -c [-m <mode>] <srcfile> (<dstdir>|<dstfile>)
8
 
9
doit=""
10
# Uncomment the following line for testing
11
#doit="echo "
12
 
13
mode=""
14
 
15
    while true; do
16
	case "$1" in
17
	    -c) ;;
18
	    -m) mode=$2; shift ;;
19
	    *) break ;;
20
        esac
21
    shift; done
22
 
23
src=$1
24
dst=$2
25
 
26
    if [ $# = 2 -a -f $src ]; then true; else
27
	echo "Usage: instcopy -c [-m <mode>] <srcfile> (<dstdir>|<dstfile>)"
28
	exit 1
29
    fi
30
 
31
if [ -d $dst ]; then
32
    dstdir=`echo $dst | sed -e 's,/$,,'`
33
    dst="$dstdir"/`basename $src`
34
else
35
    dstdir=`echo $dst | sed -e 's,/[^/]*$,,'`
36
fi
37
dsttmp=$dstdir/#inst.$$#
38
 
39
$doit cp $src $dsttmp &&
40
$doit trap "rm -f $dsttmp" 0 &&
41
if [ x"$mode" != x ]; then $doit chmod $mode $dsttmp; else true; fi &&
42
$doit rm -f $dst &&
43
$doit mv $dsttmp $dst &&
44
exit 0