Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

executable file 17 lines (16 sloc) 0.335 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/bin/sh
# usage: ifchange target temporary

target="$1"
temp="$2"
if [ "$temp" = - ]; then
    temp="tmpdata$$.tmp~"
    cat > "$temp" || exit $?
    trap 'rm -f "$temp"' 0
fi
if cmp "$target" "$temp" >/dev/null 2>&1; then
    echo "$target unchanged"
    rm -f "$temp"
else
    echo "$target updated"
    mv -f "$temp" "$target"
fi
Something went wrong with that request. Please try again.