#!/bin/bash set -o errexit -o nounset -o pipefail export PATH=~/.cargo/bin:"$PATH" find src -type f -name '*.rs.bk' -delete cargo fmt -- --force --write-mode replace n=0 while read -d '' -r path do [[ -s $path ]] || continue echo "Not formatted as auto-formatting would: ${path%.bk}" diff -u "$path" "${path%.bk}" | head -n10 n=$((n + 1)) done < <(find src -type f -name '*.rs.bk' -print0) exit "$n"