From e7e950024cd23a1de5009eac957480b234b8a6cc Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Sat, 12 Feb 2011 15:47:02 +0000 Subject: [PATCH] Import move-if-change script from gnulib. /: PR binutils/12283 * MAINTAINERS (mkinstalldirs): Comes from Automake. (move-if-change): Comes from gnulib. * move-if-change: Import version from gnulib. --- ChangeLog | 7 +++++ MAINTAINERS | 10 ++----- move-if-change | 81 +++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 81 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index de6024554..930f70d09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-02-12 Ralf Wildenhues + + PR binutils/12283 + * MAINTAINERS (mkinstalldirs): Comes from Automake. + (move-if-change): Comes from gnulib. + * move-if-change: Import version from gnulib. + 2011-02-12 Ralf Wildenhues Sync from GCC: diff --git a/MAINTAINERS b/MAINTAINERS index a471c907e..046c5ea82 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -38,7 +38,7 @@ config.guess; config.sub; readline/support/config.{sub,guess} binutils@sourceware.org gdb-patches@sourceware.org -depcomp +depcomp; mkinstalldirs Send bug reports and patches to bug-automake@gnu.org. gdb/; readline/; sim/; GDB's part of include/ @@ -69,12 +69,8 @@ ltconfig; ltmain.sh; ltcf-*.sh sources or submitted to the master file maintainer and brought in via a merge. -mkinstalldirs; move-if-change - autoconf: http://gnu.org - Patches to autoconf-patches@gnu.org. - Changes need to be done in tandem with the official AUTOCONF - sources or submitted to the master file maintainer and brought - in via a merge. +move-if-change + Send bug reports and patches to bug-gnulib@gnu.org. symlink-tree gcc: http://gcc.gnu.org diff --git a/move-if-change b/move-if-change index ff74a556d..e7ba25e31 100755 --- a/move-if-change +++ b/move-if-change @@ -2,21 +2,82 @@ # Like mv $1 $2, but if the files are the same, just delete $1. # Status is zero if successful, nonzero otherwise. -usage="$0: usage: $0 SOURCE DEST" +VERSION='2011-01-28 20:09'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. -case $# in -2) ;; -*) echo "$usage" >&2; exit 1;; -esac +# Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc. -for arg in "$1" "$2"; do +# 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 3 of the License, 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 . + +usage="usage: $0 SOURCE DEST" + +help="$usage + or: $0 OPTION +If SOURCE is different than DEST, then move it to DEST; else remove SOURCE. + + --help display this help and exit + --version output version information and exit + +The variable CMPPROG can be used to specify an alternative to \`cmp'. + +Report bugs to ." + +version=`expr "$VERSION" : '\([^ ]*\)'` +version="move-if-change (gnulib) $version +Copyright (C) 2011 Free Software Foundation, Inc. +License GPLv3+: GNU GPL version 3 or later +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law." + +cmpprog=${CMPPROG-cmp} + +for arg +do case $arg in - -*) echo "$usage" >&2; exit 1;; + --help | --hel | --he | --h) + exec echo "$help" ;; + --version | --versio | --versi | --vers | --ver | --ve | --v) + exec echo "$version" ;; + --) + shift + break ;; + -*) + echo "$0: invalid option: $arg" >&2 + exit 1 ;; + *) + break ;; esac done -if test -r "$2" && cmp -s "$1" "$2"; then - rm -f "$1" +test $# -eq 2 || { echo "$0: $usage" >&2; exit 1; } + +if test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then + rm -f -- "$1" else - mv -f "$1" "$2" + if mv -f -- "$1" "$2"; then :; else + # Ignore failure due to a concurrent move-if-change. + test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1" + fi fi + +## Local Variables: +## eval: (add-hook 'write-file-hooks 'time-stamp) +## time-stamp-start: "VERSION='" +## time-stamp-format: "%:y-%02m-%02d %02H:%02M" +## time-stamp-time-zone: "UTC" +## time-stamp-end: "'; # UTC" +## End: