Deleted Added
full compact
install-sh (249140) install-sh (249141)
1#!/bin/sh
2# install - install a program, script, or datafile
3
1#!/bin/sh
2# install - install a program, script, or datafile
3
4scriptversion=2009-04-28.21; # UTC
4scriptversion=2011-11-20.07; # UTC
5
6# This originates from X11R5 (mit/util/scripts/install.sh), which was
7# later released in X11R6 (xc/config/util/install.sh) with the
8# following copyright and license.
9#
10# Copyright (C) 1994 X Consortium
11#
12# Permission is hereby granted, free of charge, to any person obtaining a copy

--- 17 unchanged lines hidden (view full) ---

30# be used in advertising or otherwise to promote the sale, use or other deal-
31# ings in this Software without prior written authorization from the X Consor-
32# tium.
33#
34#
35# FSF changes to this file are in the public domain.
36#
37# Calling this script install-sh is preferred over install.sh, to prevent
5
6# This originates from X11R5 (mit/util/scripts/install.sh), which was
7# later released in X11R6 (xc/config/util/install.sh) with the
8# following copyright and license.
9#
10# Copyright (C) 1994 X Consortium
11#
12# Permission is hereby granted, free of charge, to any person obtaining a copy

--- 17 unchanged lines hidden (view full) ---

30# be used in advertising or otherwise to promote the sale, use or other deal-
31# ings in this Software without prior written authorization from the X Consor-
32# tium.
33#
34#
35# FSF changes to this file are in the public domain.
36#
37# Calling this script install-sh is preferred over install.sh, to prevent
38# `make' implicit rules from creating a file called install from it
38# 'make' implicit rules from creating a file called install from it
39# when there is no Makefile.
40#
41# This script is compatible with the BSD install script, but was written
42# from scratch.
43
44nl='
45'
46IFS=" "" $nl"

--- 104 unchanged lines hidden (view full) ---

151 shift;;
152
153 -o) chowncmd="$chownprog $2"
154 shift;;
155
156 -s) stripcmd=$stripprog;;
157
158 -t) dst_arg=$2
39# when there is no Makefile.
40#
41# This script is compatible with the BSD install script, but was written
42# from scratch.
43
44nl='
45'
46IFS=" "" $nl"

--- 104 unchanged lines hidden (view full) ---

151 shift;;
152
153 -o) chowncmd="$chownprog $2"
154 shift;;
155
156 -s) stripcmd=$stripprog;;
157
158 -t) dst_arg=$2
159 # Protect names problematic for 'test' and other utilities.
160 case $dst_arg in
161 -* | [=\(\)!]) dst_arg=./$dst_arg;;
162 esac
159 shift;;
160
161 -T) no_target_directory=true;;
162
163 --version) echo "$0 $scriptversion"; exit $?;;
164
165 --) shift
166 break;;

--- 14 unchanged lines hidden (view full) ---

181 do
182 if test -n "$dst_arg"; then
183 # $@ is not empty: it contains at least $arg.
184 set fnord "$@" "$dst_arg"
185 shift # fnord
186 fi
187 shift # arg
188 dst_arg=$arg
163 shift;;
164
165 -T) no_target_directory=true;;
166
167 --version) echo "$0 $scriptversion"; exit $?;;
168
169 --) shift
170 break;;

--- 14 unchanged lines hidden (view full) ---

185 do
186 if test -n "$dst_arg"; then
187 # $@ is not empty: it contains at least $arg.
188 set fnord "$@" "$dst_arg"
189 shift # fnord
190 fi
191 shift # arg
192 dst_arg=$arg
193 # Protect names problematic for 'test' and other utilities.
194 case $dst_arg in
195 -* | [=\(\)!]) dst_arg=./$dst_arg;;
196 esac
189 done
190fi
191
192if test $# -eq 0; then
193 if test -z "$dir_arg"; then
194 echo "$0: no input file specified." >&2
195 exit 1
196 fi
197 done
198fi
199
200if test $# -eq 0; then
201 if test -z "$dir_arg"; then
202 echo "$0: no input file specified." >&2
203 exit 1
204 fi
197 # It's OK to call `install-sh -d' without argument.
205 # It's OK to call 'install-sh -d' without argument.
198 # This can happen when creating conditional directories.
199 exit 0
200fi
201
202if test -z "$dir_arg"; then
206 # This can happen when creating conditional directories.
207 exit 0
208fi
209
210if test -z "$dir_arg"; then
203 trap '(exit $?); exit' 1 2 13 15
211 do_exit='(exit $ret); exit $ret'
212 trap "ret=129; $do_exit" 1
213 trap "ret=130; $do_exit" 2
214 trap "ret=141; $do_exit" 13
215 trap "ret=143; $do_exit" 15
204
205 # Set umask so as not to create temps with too-generous modes.
206 # However, 'strip' requires both read and write access to temps.
207 case $mode in
208 # Optimize common cases.
209 *644) cp_umask=133;;
210 *755) cp_umask=22;;
211

--- 11 unchanged lines hidden (view full) ---

223 u_plus_rw=,u+rw
224 fi
225 cp_umask=$mode$u_plus_rw;;
226 esac
227fi
228
229for src
230do
216
217 # Set umask so as not to create temps with too-generous modes.
218 # However, 'strip' requires both read and write access to temps.
219 case $mode in
220 # Optimize common cases.
221 *644) cp_umask=133;;
222 *755) cp_umask=22;;
223

--- 11 unchanged lines hidden (view full) ---

235 u_plus_rw=,u+rw
236 fi
237 cp_umask=$mode$u_plus_rw;;
238 esac
239fi
240
241for src
242do
231 # Protect names starting with `-'.
243 # Protect names problematic for 'test' and other utilities.
232 case $src in
244 case $src in
233 -*) src=./$src;;
245 -* | [=\(\)!]) src=./$src;;
234 esac
235
236 if test -n "$dir_arg"; then
237 dst=$src
238 dstdir=$dst
239 test -d "$dstdir"
240 dstdir_status=$?
241 else

--- 5 unchanged lines hidden (view full) ---

247 echo "$0: $src does not exist." >&2
248 exit 1
249 fi
250
251 if test -z "$dst_arg"; then
252 echo "$0: no destination specified." >&2
253 exit 1
254 fi
246 esac
247
248 if test -n "$dir_arg"; then
249 dst=$src
250 dstdir=$dst
251 test -d "$dstdir"
252 dstdir_status=$?
253 else

--- 5 unchanged lines hidden (view full) ---

259 echo "$0: $src does not exist." >&2
260 exit 1
261 fi
262
263 if test -z "$dst_arg"; then
264 echo "$0: no destination specified." >&2
265 exit 1
266 fi
255
256 dst=$dst_arg
267 dst=$dst_arg
257 # Protect names starting with `-'.
258 case $dst in
259 -*) dst=./$dst;;
260 esac
261
262 # If destination is a directory, append the input filename; won't work
263 # if double slashes aren't ignored.
264 if test -d "$dst"; then
265 if test -n "$no_target_directory"; then
266 echo "$0: $dst_arg: Is a directory" >&2
267 exit 1
268 fi

--- 73 unchanged lines hidden (view full) ---

342 trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
343
344 if (umask $mkdir_umask &&
345 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
346 then
347 if test -z "$dir_arg" || {
348 # Check for POSIX incompatibilities with -m.
349 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
268
269 # If destination is a directory, append the input filename; won't work
270 # if double slashes aren't ignored.
271 if test -d "$dst"; then
272 if test -n "$no_target_directory"; then
273 echo "$0: $dst_arg: Is a directory" >&2
274 exit 1
275 fi

--- 73 unchanged lines hidden (view full) ---

349 trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
350
351 if (umask $mkdir_umask &&
352 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
353 then
354 if test -z "$dir_arg" || {
355 # Check for POSIX incompatibilities with -m.
356 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
350 # other-writeable bit of parent directory when it shouldn't.
357 # other-writable bit of parent directory when it shouldn't.
351 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
352 ls_ld_tmpdir=`ls -ld "$tmpdir"`
353 case $ls_ld_tmpdir in
354 d????-?r-*) different_mode=700;;
355 d????-?--*) different_mode=755;;
356 *) false;;
357 esac &&
358 $mkdirprog -m$different_mode -p -- "$tmpdir" && {

--- 21 unchanged lines hidden (view full) ---

380 else
381
382 # The umask is ridiculous, or mkdir does not conform to POSIX,
383 # or it failed possibly due to a race condition. Create the
384 # directory the slow way, step by step, checking for races as we go.
385
386 case $dstdir in
387 /*) prefix='/';;
358 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
359 ls_ld_tmpdir=`ls -ld "$tmpdir"`
360 case $ls_ld_tmpdir in
361 d????-?r-*) different_mode=700;;
362 d????-?--*) different_mode=755;;
363 *) false;;
364 esac &&
365 $mkdirprog -m$different_mode -p -- "$tmpdir" && {

--- 21 unchanged lines hidden (view full) ---

387 else
388
389 # The umask is ridiculous, or mkdir does not conform to POSIX,
390 # or it failed possibly due to a race condition. Create the
391 # directory the slow way, step by step, checking for races as we go.
392
393 case $dstdir in
394 /*) prefix='/';;
388 -*) prefix='./';;
395 [-=\(\)!]*) prefix='./';;
389 *) prefix='';;
390 esac
391
392 eval "$initialize_posix_glob"
393
394 oIFS=$IFS
395 IFS=/
396 $posix_glob set -f
397 set fnord $dstdir
398 shift
399 $posix_glob set +f
400 IFS=$oIFS
401
402 prefixes=
403
404 for d
405 do
396 *) prefix='';;
397 esac
398
399 eval "$initialize_posix_glob"
400
401 oIFS=$IFS
402 IFS=/
403 $posix_glob set -f
404 set fnord $dstdir
405 shift
406 $posix_glob set +f
407 IFS=$oIFS
408
409 prefixes=
410
411 for d
412 do
406 test -z "$d" && continue
413 test X"$d" = X && continue
407
408 prefix=$prefix$d
409 if test -d "$prefix"; then
410 prefixes=
411 else
412 if $posix_mkdir; then
413 (umask=$mkdir_umask &&
414 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break

--- 106 unchanged lines hidden ---
414
415 prefix=$prefix$d
416 if test -d "$prefix"; then
417 prefixes=
418 else
419 if $posix_mkdir; then
420 (umask=$mkdir_umask &&
421 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break

--- 106 unchanged lines hidden ---