* Miscellaneous changes
- install-sh tweaks:
- . new option to preserve mtime, i.e., invoke cp -p.
+ . new option -p to preserve mtime, i.e., invoke cp -p.
+ . new option -S SUFFIX to attempt backup files using SUFFIX.
. no longer unconditionally uses -f when rm is overridden by RMPROG.
. does not chown existing directories.
#!/bin/sh
# install - install a program, script, or datafile
-scriptversion=2020-11-11.03; # UTC
+scriptversion=2020-11-13.01; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# This is like GNU 'install' as of coreutils 8.32 (2020).
mkdir_umask=22
+backupsuffix=
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
-o USER $chownprog installed files to USER.
-p pass -p to $cpprog.
-s $stripprog installed files.
+ -S SUFFIX attempt to back up existing files, with suffix SUFFIX.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
By default, rm is invoked with -f; when overridden with RMPROG,
it's up to you to specify -f if you want it.
+If -S is not specified, no backups are attempted.
+
Email bug reports to bug-automake@gnu.org.
Automake home page: https://www.gnu.org/software/automake/
"
-s) stripcmd=$stripprog;;
+ -S) backupsuffix="$2"
+ shift;;
+
-t)
is_target_a_directory=always
dst_arg=$2
then
rm -f "$dsttmp"
else
+ # If $backupsuffix is set, and the file being installed
+ # already exists, attempt a backup. Don't worry if it fails,
+ # e.g., if mv doesn't support -f.
+ if test -n "$backupsuffix" && test -f "$dst"; then
+ $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
+ fi
+
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2006-2020 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+# More install-sh checks: option -S SUFFIX should create backups.
+
+required=non-root
+. test-init.sh
+
+get_shell_script install-sh
+
+# File gets backed up if -S is specified.
+echo foo >file
+echo bar >newfile
+./install-sh -S .BAK newfile file
+test -r file.BAK
+
+: