File: MoveIfChange

package info (click to toggle)
xconq 7.2.2-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 8,296 kB
  • ctags: 9,199
  • sloc: ansic: 107,849; sh: 2,108; perl: 2,057; makefile: 1,177; sed: 161; csh: 50; awk: 49; lisp: 39
file content (19 lines) | stat: -rw-r--r-- 481 bytes parent folder | download | duplicates (39)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Rename a file only if it is different from a previously existing
# file of the same name.  This is useful for keeping make from doing
# too much work if the contents of a file haven't changed.

# This is an MPW translation of the standard GNU sh script move-if-change.

Set exit 0

If "`exists -f "{2}"`"
  Compare "{1}" "{2}" >dev:null
  If {status} != 0
    Rename -y "{1}" "{2}"
  Else
    Echo "{2}" is unchanged
    Delete -i -y "{1}"
  End
Else
  Rename -y "{1}" "{2}"
End