Skip to content

Instantly share code, notes, and snippets.

@drewbrokke
Last active July 24, 2023 16:19
Show Gist options
  • Save drewbrokke/5397f1166cfd4d828d93ff2664478411 to your computer and use it in GitHub Desktop.
Save drewbrokke/5397f1166cfd4d828d93ff2664478411 to your computer and use it in GitHub Desktop.
#!/bin/bash
function detect_unused_paths() {
local file
file="$1"
base_file_name="$(basename "${file%%.path}")"
for i in $(rg '<td>([A-Z_]+)</td>' --replace='$1' --no-line-number --no-filename --no-heading --only-matching -- "${file}") ; do
git --no-pager grep --quiet "\"${base_file_name}#${i}\"" -- '*.macro' '*.function' '*.testcase' || echo "${base_file_name}#${i}"
done
}
unused_file="unused_paths.txt"
echo "" > "${unused_file}"
for f in $(git ls-files -- '*.path') ; do
echo "checking ${f}..."
detect_unused_paths "$f" >> "${unused_file}"
done
echo "Done! See ${unused_file}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment