summaryrefslogtreecommitdiff
path: root/lib/install-sh
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2013-12-26 00:07:27 +0100
committerStefano Lattarini <stefano.lattarini@gmail.com>2013-12-26 00:07:27 +0100
commit222337e60bfc87456773a4c7cbbbd3192fde956d (patch)
tree4bef40969d4f02c785f08673e7558a3f5c6111e5 /lib/install-sh
parent6863925ddd92c8f4b44556a2bb32d958d00325ff (diff)
downloadautomake-222337e60bfc87456773a4c7cbbbd3192fde956d.tar.gz
install-sh: be stricter in catching invalid usages
Such usages (which are rejected by GNU install as well) are: - options -d and -t used together; - argument passed to option -t must be a directory; - if there are two or more SOURCEFILE arguments, the DESTINATION argument must be a directory. Note that we still allow the use of options -d and -T together, by making -d take the precedence; this is for compatibility with GNU install. This change fixes, among other things, automake bug#15376. * lib/install-sh: Adjust. * t/install-sh-unittests.sh: Enhance. * NEWS: Update. * THANKS: Add reporter of bug#15376. Helped-by: Tobias Hansen <thansen@debian.org> Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 'lib/install-sh')
-rwxr-xr-xlib/install-sh31
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/install-sh b/lib/install-sh
index 043673775..d8de87f30 100755
--- a/lib/install-sh
+++ b/lib/install-sh
@@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile
-scriptversion=2013-10-30.23; # UTC
+scriptversion=2013-12-25.23; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
@@ -82,7 +82,7 @@ dir_arg=
dst_arg=
copy_on_change=false
-no_target_directory=
+is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@@ -139,14 +139,16 @@ while test $# -ne 0; do
-s) stripcmd=$stripprog;;
- -t) dst_arg=$2
+ -t)
+ is_target_a_directory=always
+ dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
- -T) no_target_directory=true;;
+ -T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
@@ -161,6 +163,16 @@ while test $# -ne 0; do
shift
done
+# We allow the use of options -d and -T together, by making -d
+# take the precedence; this is for compatibility with GNU install.
+
+if test -n "$dir_arg"; then
+ if test -n "$dst_arg"; then
+ echo "$0: target directory not allowed when installing a directory." >&2
+ exit 1
+ fi
+fi
+
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
@@ -181,6 +193,15 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
done
fi
+if test -z "$dir_arg"; then
+ if test $# -gt 1 || test "$is_target_a_directory" = always; then
+ if test ! -d "$dst_arg"; then
+ echo "$0: $dst_arg: Is not a directory." >&2
+ exit 1
+ fi
+ fi
+fi
+
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
@@ -253,7 +274,7 @@ do
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
- if test -n "$no_target_directory"; then
+ if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi