Annotation of src/usr.bin/less/install.sh, Revision 1.2
1.1 etheisen 1: #!/bin/sh
1.2 ! niklas 2: # $OpenBSD$
! 3:
1.1 etheisen 4:
5: #
6: # install - install a program, script, or datafile
7: # This comes from X11R5; it is not part of GNU.
8: #
9: # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
10: #
11: # This script is compatible with the BSD install script, but was written
12: # from scratch.
13: #
14:
15:
16: # set DOITPROG to echo to test this script
17:
18: # Don't use :- since 4.3BSD and earlier shells don't like it.
19: doit="${DOITPROG-}"
20:
21:
22: # put in absolute paths if you don't have them in your path; or use env. vars.
23:
24: mvprog="${MVPROG-mv}"
25: cpprog="${CPPROG-cp}"
26: chmodprog="${CHMODPROG-chmod}"
27: chownprog="${CHOWNPROG-chown}"
28: chgrpprog="${CHGRPPROG-chgrp}"
29: stripprog="${STRIPPROG-strip}"
30: rmprog="${RMPROG-rm}"
31:
32: instcmd="$mvprog"
33: chmodcmd=""
34: chowncmd=""
35: chgrpcmd=""
36: stripcmd=""
37: rmcmd="$rmprog -f"
38: mvcmd="$mvprog"
39: src=""
40: dst=""
41:
42: while [ x"$1" != x ]; do
43: case $1 in
44: -c) instcmd="$cpprog"
45: shift
46: continue;;
47:
48: -m) chmodcmd="$chmodprog $2"
49: shift
50: shift
51: continue;;
52:
53: -o) chowncmd="$chownprog $2"
54: shift
55: shift
56: continue;;
57:
58: -g) chgrpcmd="$chgrpprog $2"
59: shift
60: shift
61: continue;;
62:
63: -s) stripcmd="$stripprog"
64: shift
65: continue;;
66:
67: *) if [ x"$src" = x ]
68: then
69: src=$1
70: else
71: dst=$1
72: fi
73: shift
74: continue;;
75: esac
76: done
77:
78: if [ x"$src" = x ]
79: then
80: echo "install: no input file specified"
81: exit 1
82: fi
83:
84: if [ x"$dst" = x ]
85: then
86: echo "install: no destination specified"
87: exit 1
88: fi
89:
90:
91: # If destination is a directory, append the input filename; if your system
92: # does not like double slashes in filenames, you may need to add some logic
93:
94: if [ -d $dst ]
95: then
96: dst="$dst"/`basename $src`
97: fi
98:
99: # Make a temp file name in the proper directory.
100:
101: dstdir=`dirname $dst`
102: dsttmp=$dstdir/#inst.$$#
103:
104: # Move or copy the file name to the temp name
105:
106: $doit $instcmd $src $dsttmp
107:
108: # and set any options; do chmod last to preserve setuid bits
109:
110: if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi
111: if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi
112: if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi
113: if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi
114:
115: # Now rename the file to the real destination.
116:
117: $doit $rmcmd $dst
118: $doit $mvcmd $dsttmp $dst
119:
120:
121: exit 0