Bug 1874684 - Part 17: Fix uninitialised variable warnings from clang-tidy. r=allstarschh
[gecko.git] / build / autoconf / install-sh
bloba4be13e59ffc2d226cdb3066247956c110bd400d
1 #!/bin/sh
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # install - install a program, script, or datafile
9 # This comes from X11R5; it is not part of GNU.
11 # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
13 # This script is compatible with the BSD install script, but was written
14 # from scratch.
18 # set DOITPROG to echo to test this script
20 # Don't use :- since 4.3BSD and earlier shells don't like it.
21 doit="${DOITPROG-}"
24 # put in absolute paths if you don't have them in your path; or use env. vars.
26 mvprog="${MVPROG-mv}"
27 cpprog="${CPPROG-cp}"
28 chmodprog="${CHMODPROG-chmod}"
29 chownprog="${CHOWNPROG-chown}"
30 chgrpprog="${CHGRPPROG-chgrp}"
31 stripprog="${STRIPPROG-strip}"
32 rmprog="${RMPROG-rm}"
34 instcmd="$mvprog"
35 chmodcmd=""
36 chowncmd=""
37 chgrpcmd=""
38 stripcmd=""
39 rmcmd="$rmprog -f"
40 mvcmd="$mvprog"
41 src=""
42 dst=""
44 while [ x"$1" != x ]; do
45 case $1 in
46 -c) instcmd="$cpprog"
47 shift
48 continue;;
50 -m) chmodcmd="$chmodprog $2"
51 shift
52 shift
53 continue;;
55 -o) chowncmd="$chownprog $2"
56 shift
57 shift
58 continue;;
60 -g) chgrpcmd="$chgrpprog $2"
61 shift
62 shift
63 continue;;
65 -s) stripcmd="$stripprog"
66 shift
67 continue;;
69 *) if [ x"$src" = x ]
70 then
71 src=$1
72 else
73 dst=$1
75 shift
76 continue;;
77 esac
78 done
80 if [ x"$src" = x ]
81 then
82 echo "install: no input file specified"
83 exit 1
86 if [ x"$dst" = x ]
87 then
88 echo "install: no destination specified"
89 exit 1
93 # If destination is a directory, append the input filename; if your system
94 # does not like double slashes in filenames, you may need to add some logic
96 if [ -d $dst ]
97 then
98 dst="$dst"/`basename $src`
101 # Make a temp file name in the proper directory.
103 dstdir=`dirname $dst`
104 dsttmp=$dstdir/#inst.$$#
106 # Move or copy the file name to the temp name
108 $doit $instcmd $src $dsttmp
110 # and set any options; do chmod last to preserve setuid bits
112 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi
113 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi
114 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi
115 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi
117 # Now rename the file to the real destination.
119 $doit $rmcmd $dst
120 $doit $mvcmd $dsttmp $dst
123 exit 0