]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - scripts/documentation-file-ref-check
Documentation: add script and build target to check for broken file references
[mirror_ubuntu-bionic-kernel.git] / scripts / documentation-file-ref-check
diff --git a/scripts/documentation-file-ref-check b/scripts/documentation-file-ref-check
new file mode 100755 (executable)
index 0000000..bc16599
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+# Treewide grep for references to files under Documentation, and report
+# non-existing files in stderr.
+
+for f in $(git ls-files); do
+       for ref in $(grep -ho "Documentation/[A-Za-z0-9_.,~/*+-]*" "$f"); do
+               # presume trailing . and , are not part of the name
+               ref=${ref%%[.,]}
+
+               # use ls to handle wildcards
+               if ! ls $ref >/dev/null 2>&1; then
+                       echo "$f: $ref" >&2
+               fi
+       done
+done