From 0846cebb135295fa7c838f40b11e1db15e4b7098 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 6 Sep 2005 20:00:24 +0000 Subject: [PATCH] * config/move-if-change: Don't output "$2 is unchanged"; suggested by Ben Elliston. Handle weird characters correctly. --- ChangeLog | 5 +++++ config/move-if-change | 27 ++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b0b06dd..73ce3078 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-09-06 Paul Eggert + + * config/move-if-change: Don't output "$2 is unchanged"; + suggested by Ben Elliston. Handle weird characters correctly. + 2005-09-06 Stepan Kasal * lib/autoconf/libs.m4 (AC_SEARCH_LIBS): Merge the two AC_LINK_IFELSE diff --git a/config/move-if-change b/config/move-if-change index 5cdc3b4d..ff74a556 100755 --- a/config/move-if-change +++ b/config/move-if-change @@ -1,13 +1,22 @@ #!/bin/sh # Like mv $1 $2, but if the files are the same, just delete $1. -# Status is 0 if $2 is changed, 1 otherwise. -if test -r $2; then - if cmp -s $1 $2; then - echo $2 is unchanged - rm -f $1 - else - mv -f $1 $2 - fi +# Status is zero if successful, nonzero otherwise. + +usage="$0: usage: $0 SOURCE DEST" + +case $# in +2) ;; +*) echo "$usage" >&2; exit 1;; +esac + +for arg in "$1" "$2"; do + case $arg in + -*) echo "$usage" >&2; exit 1;; + esac +done + +if test -r "$2" && cmp -s "$1" "$2"; then + rm -f "$1" else - mv -f $1 $2 + mv -f "$1" "$2" fi -- 2.11.4.GIT