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 9doit="" 10# Uncomment the following line for testing 11#doit="echo " 12 13mode="" 14 15 while true; do 16 case "$1" in 17 -c) ;; 18 -m) mode=$2; shift ;; 19 *) break ;; 20 esac 21 shift; done 22 23src=$1 24dst=$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 31if [ -d $dst ]; then 32 dstdir=`echo $dst | sed -e 's,/$,,'` 33 dst="$dstdir"/`basename $src` 34else 35 dstdir=`echo $dst | sed -e 's,/[^/]*$,,'` 36fi 37dsttmp=$dstdir/#inst.$$# 38 39$doit cp $src $dsttmp && 40$doit trap "rm -f $dsttmp" 0 && 41if [ x"$mode" != x ]; then $doit chmod $mode $dsttmp; else true; fi && 42$doit rm -f $dst && 43$doit mv $dsttmp $dst && 44exit 0 45