Fixed return values that got inverted during conversion from using
[AROS.git] / tools / cxref / install-sh
blob2bf90c883cec412777ba8b4fb49c0ed677a2284d
1 #!/bin/sh
3 # Installation script for Unices without a BSD style install (e.g. HP-UX).
5 # Written by Andrew M. Bishop
7 # This file Copyright 1995,96,97,98 Andrew M. Bishop
8 # It may be distributed under the GNU Public License, version 2, or
9 # any higher version. See section COPYING of the GNU Public license
10 # for conditions under which this file may be redistributed.
13 if [ $# = "0" ]; then
14 echo "A simple installation script"
15 echo "usage: install.sh [-c] -d dir"
16 echo " install.sh [-c] [-m mode] [-g group] [-o owner] file destination"
17 exit 1
20 if [ $1 = "-c" ]; then
21 shift
24 if [ $1 = "-d" ]; then
26 if [ "x$2" = "x" ]; then
27 echo "Directory not specified"
28 exit 1
31 dir=''
32 dirs=`echo $2 | sed 's%/% %g'`
33 for d in $dirs; do
34 dir="$dir/$d";
35 [ -d $dir ] || mkdir $dir
36 done
38 else
40 mode=
41 owner=
42 group=
44 while [ ! $# = 0 ]; do
46 case $1 in
48 -m) shift; mode=$1;;
49 -o) shift; owner=$1;;
50 -g) shift; group=$1;;
51 -*) echo "Unrecognised option $1"; exit 1;;
53 *) src=$1; shift; dst=$1;;
55 esac
56 shift
57 done
59 if [ "x$src" = "x" -o "x$dst" = "x" ]; then
60 echo "Source and destination not specified"
61 exit 1
64 if [ -d $dst ]; then
65 dst=$dst/`basename $src`
68 if cp $src $dst; then
69 [ $mode ] && chmod $mode $dst
70 [ $group ] && chgrp $group $dst
71 [ $owner ] && chown $owner $dst
72 else
73 echo Copy of $src to $dst failed
74 exit 1
79 exit 0