source: trunk/build_support/move-if-change @ 1853

Last change on this file since 1853 was 1853, checked in by Peter, 15 years ago

adding verbose option in move-if-change

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 532 bytes
Line 
1#!/bin/sh
2# Like mv $1 $2, but if the files are the same, just delete $1.
3# Status is zero if successful, nonzero otherwise.
4
5usage="$0: usage: $0 [-v] SOURCE DEST"
6
7if test "x$1" = "x-v"; then
8  verbose=yes
9  shift
10fi
11
12case $# in
132) ;;
14*) echo "$usage" >&2; exit 1;;
15esac
16
17for arg in "$1" "$2"; do
18  case $arg in
19   -*) echo "$usage" >&2; exit 1;;
20  esac
21done
22
23if test -r "$2" && cmp -s "$1" "$2"; then
24  if test "x$verbose" = "xyes"; then
25    echo "move-if-change: \`$2' is up to date"
26  fi
27  rm -f "$1"
28else
29  mv -f "$1" "$2"
30fi
Note: See TracBrowser for help on using the repository browser.