#!/bin/sh
# install - install a program, script, or datafile
-scriptversion=2006-01-12.21
+scriptversion=2006-05-11.20
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
+nl='
+'
+IFS=" "" $nl"
+
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
-# put in absolute paths if you don't have them in your path; or use env. vars.
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
-while test -n "$1"; do
+while test $# -ne 0; do
case $1 in
-c) shift
continue;;
--version) echo "$0 $scriptversion"; exit $?;;
- *) # When -d is used, all remaining arguments are directories to create.
- # When -t is used, the destination is already specified.
- test -n "$dir_arg$dstarg" && break
- # Otherwise, the last argument is the destination. Remove it from $@.
- for arg
- do
- if test -n "$dstarg"; then
- # $@ is not empty: it contains at least $arg.
- set fnord "$@" "$dstarg"
- shift # fnord
- fi
- shift # arg
- dstarg=$arg
- done
+ --) shift
break;;
+
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;
+
+ *) break;;
esac
done
-if test -z "$1"; then
+if test $# -ne 0 && test -z "$dir_arg$dstarg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from $@.
+ for arg
+ do
+ if test -n "$dstarg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dstarg"
+ shift # fnord
+ fi
+ shift # arg
+ dstarg=$arg
+ done
+fi
+
+if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
- X"$dst" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
+ X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
# step, checking for races as we go.
case $dstdir in
- /*) pathcomp=/ ;;
- -*) pathcomp=./ ;;
- *) pathcomp= ;;
+ /*) prefix=/ ;;
+ -*) prefix=./ ;;
+ *) prefix= ;;
esac
case $posix_glob in
$posix_glob && set +f
IFS=$oIFS
+ prefixes=
+
for d
do
- test "x$d" = x && continue
+ test -z "$d" && continue
- pathcomp=$pathcomp$d
- if test ! -d "$pathcomp"; then
- $mkdirprog "$pathcomp"
- # Don't fail if two instances are running concurrently.
- test -d "$pathcomp" || exit 1
+ prefix=$prefix$d
+ if test -d "$prefix"; then
+ prefixes=
+ else
+ if $posix_mkdir; then
+ $mkdirprog -m "$mkdir_mode" -p -- "$dstdir" && break
+ # Don't fail if two instances are running concurrently.
+ test -d "$prefix" || exit 1
+ else
+ case $prefix in
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) qprefix=$prefix;;
+ esac
+ prefixes="$prefixes '$qprefix'"
+ fi
fi
- pathcomp=$pathcomp/
+ prefix=$prefix/
done
- obsolete_mkdir_used=true
+
+ if test -n "$prefixes"; then
+ # Don't fail if two instances are running concurrently.
+ eval "\$mkdirprog $prefixes" || test -d "$dstdir" || exit 1
+ obsolete_mkdir_used=true
+ fi
fi
fi