3 # Written by Rich Felker, originally as part of musl libc.
4 # Multi-licensed under MIT, 0BSD, and CC0.
6 # This is an actually-safe install command which installs the new
7 # file atomically in the new location, rather than overwriting
12 printf "usage: %s [-D] [-l] [-m mode] src dest\n" "$0" 1>&2
20 while getopts Dlm
: name
; do
28 shift $
(($OPTIND - 1))
30 test "$#" -eq 2 || usage
36 */) printf "%s: %s ends in /\n", "$0" "$dst" 1>&2 ; exit 1 ;;
42 if test "$mkdirp" ; then
45 */*) mkdir
-p "${dst%/*}" ;;
49 trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP
53 if test "$symlink" ; then
63 printf "%s: %s is a directory\n" "$0" "$dst" 1>&2