xref: /openbsd-src/gnu/usr.bin/gcc/gcc/move-if-change (revision c87b03e512fc05ed6e0222f6fb0ae86264b1d05b)
1*c87b03e5Sespie#!/bin/sh
2*c87b03e5Sespie# Like mv $1 $2, but if the files are the same, just delete $1.
3*c87b03e5Sespie# Status is 0 if $2 is changed, 1 otherwise.
4*c87b03e5Sespieif
5*c87b03e5Sespietest -r $2
6*c87b03e5Sespiethen
7*c87b03e5Sespieif
8*c87b03e5Sespiecmp -s $1 $2
9*c87b03e5Sespiethen
10*c87b03e5Sespieecho $2 is unchanged
11*c87b03e5Sespierm -f $1
12*c87b03e5Sespieelse
13*c87b03e5Sespiemv -f $1 $2
14*c87b03e5Sespiefi
15*c87b03e5Sespieelse
16*c87b03e5Sespiemv -f $1 $2
17*c87b03e5Sespiefi
18