git @ Cat's Eye Technologies Dipple / master sh / continuable-diffr.sh
master

Tree @master (Download .tar.gz)

continuable-diffr.sh @masterraw · history · blame

#!/bin/sh

# Recurse through all the files in the current directory and compare
# them to their counterparts in the given directory.
#
# SPDX-FileCopyrightText: Chris Pressey, the original author of this work, has dedicated it to the public domain.
# For more information, please refer to <https://unlicense.org/>
# SPDX-License-Identifier: Unlicense

# Different from `diff --brief --recursive` because:
# 1) will verbosely report every filename as it compares it
# 2) allows to continue a long recursion by skip until a given filename
#    (usage: SKIPUNTIL="./foo/bar.txt" continuable-diffr.sh)
#
# Possibly best to pipe the output of this to 'tee /tmp/diffs.txt'
# then use `grep ' differ' /tmp/diffs.txt` to find the differing ones.

TARGET=$1

#SKIPUNTIL="./test.sh"
MANIFEST=/tmp/manifest.lst
ACTIVE=N
if [ "x$SKIPUNTIL" = "x" ]; then
    ACTIVE=Y
else
    echo "Skipping until $SKIPUNTIL"
    ACTIVE=N
fi

if [ ! -r "$MANIFEST" ]; then
    echo "Cannot read $MANIFEST"
    echo "Collecting manifest"
    find . | sort > "$MANIFEST"
fi

echo "Traversing manifest"
while read F
do
    if [ "$F" = "$SKIPUNTIL" ]; then
        ACTIVE=Y
    fi
    if [ ! -d "$F" ]; then
        if [ $ACTIVE != "Y" ]; then
            echo -n ""
            # echo "(skipping $F)"
        elif diff --brief --new-file "$F" "$TARGET$F"; then
            echo "$F"
        else
            echo "!!! $F"
        fi
    fi
done <"$MANIFEST"