summaryrefslogtreecommitdiffstats
path: root/contrib/top/install
blob: d8b6283eaca1f78a9b9a09003c46fac98513588b (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
65
66
67
68
69
#!/bin/sh
#
# this shell script is amazingly similar to the old and lamented
# BSD "install" command.  It recognized the following options:
#
#	-o target file owner
#	-m target file mode
#	-g target file group owner
#
#
# scan the options
#
while [ $# -gt 0 ]; do
    case $1 in
      -o)
	owner=$2
	shift ; shift
	;;

      -m)
	mode=$2
	shift; shift
	;;

      -g)
	group=$2
	shift ; shift
	;;

      -*)
	echo "install: unknown option $1"
	exit
	;;

      *)
	break
	;;
    esac
done
#
# we need two more:  filename and destination
#
if [ $# -ne 2 ]; then
    echo "Usage:  install [ -o owner ] [ -m mode ] [ -g group ] file destination"
    exit
fi
#
# first, copy
#
cp $1 $2
#
# normalize the name
#
dest=$2
if [ -d $2 ]; then
    dest=$2/`basename $1`
fi
#
# do optional things
#
if [ "$owner" ]; then
    chown $owner $dest
fi
if [ "$group" ]; then
    chgrp $group $dest
fi
if [ "$mode" ]; then
    chmod $mode $dest
fi
OpenPOWER on IntegriCloud