1 | #!/bin/sh |
1 | #!/bin/sh |
2 | # install - install a program, script, or datafile |
2 | # install - install a program, script, or datafile |
3 | |
3 | |
4 | scriptversion=2004-10-22.00 |
4 | scriptversion=2005-05-14.22 |
5 | |
5 | |
6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was |
6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was |
7 | # later released in X11R6 (xc/config/util/install.sh) with the |
7 | # later released in X11R6 (xc/config/util/install.sh) with the |
8 | # following copyright and license. |
8 | # following copyright and license. |
9 | # |
9 | # |
… | |
… | |
107 | -g) chgrpcmd="$chgrpprog $2" |
107 | -g) chgrpcmd="$chgrpprog $2" |
108 | shift |
108 | shift |
109 | shift |
109 | shift |
110 | continue;; |
110 | continue;; |
111 | |
111 | |
112 | --help) echo "$usage"; exit 0;; |
112 | --help) echo "$usage"; exit $?;; |
113 | |
113 | |
114 | -m) chmodcmd="$chmodprog $2" |
114 | -m) chmodcmd="$chmodprog $2" |
115 | shift |
115 | shift |
116 | shift |
116 | shift |
117 | continue;; |
117 | continue;; |
… | |
… | |
132 | |
132 | |
133 | -T) no_target_directory=true |
133 | -T) no_target_directory=true |
134 | shift |
134 | shift |
135 | continue;; |
135 | continue;; |
136 | |
136 | |
137 | --version) echo "$0 $scriptversion"; exit 0;; |
137 | --version) echo "$0 $scriptversion"; exit $?;; |
138 | |
138 | |
139 | *) # When -d is used, all remaining arguments are directories to create. |
139 | *) # When -d is used, all remaining arguments are directories to create. |
140 | # When -t is used, the destination is already specified. |
140 | # When -t is used, the destination is already specified. |
141 | test -n "$dir_arg$dstarg" && break |
141 | test -n "$dir_arg$dstarg" && break |
142 | # Otherwise, the last argument is the destination. Remove it from $@. |
142 | # Otherwise, the last argument is the destination. Remove it from $@. |
… | |
… | |
294 | if test -f "$dstdir/$dstfile"; then |
294 | if test -f "$dstdir/$dstfile"; then |
295 | $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ |
295 | $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ |
296 | || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ |
296 | || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ |
297 | || { |
297 | || { |
298 | echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 |
298 | echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 |
299 | (exit 1); exit |
299 | (exit 1); exit 1 |
300 | } |
300 | } |
301 | else |
301 | else |
302 | : |
302 | : |
303 | fi |
303 | fi |
304 | } && |
304 | } && |
305 | |
305 | |
306 | # Now rename the file to the real destination. |
306 | # Now rename the file to the real destination. |
307 | $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" |
307 | $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" |
308 | } |
308 | } |
309 | } |
309 | } |
310 | fi || { (exit 1); exit; } |
310 | fi || { (exit 1); exit 1; } |
311 | done |
311 | done |
312 | |
312 | |
313 | # The final little trick to "correctly" pass the exit status to the exit trap. |
313 | # The final little trick to "correctly" pass the exit status to the exit trap. |
314 | { |
314 | { |
315 | (exit 0); exit |
315 | (exit 0); exit 0 |
316 | } |
316 | } |
317 | |
317 | |
318 | # Local variables: |
318 | # Local variables: |
319 | # eval: (add-hook 'write-file-hooks 'time-stamp) |
319 | # eval: (add-hook 'write-file-hooks 'time-stamp) |
320 | # time-stamp-start: "scriptversion=" |
320 | # time-stamp-start: "scriptversion=" |