Last active
March 29, 2025 05:40
-
-
Save fionn/0813947b159762330be46dd0dcc11455 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eo pipefail | |
function main { | |
local threshold="${1:-2}" | |
local -r pattern="${2:-*}" | |
((threshold++)) | |
count=$( (pcre2grep -IO "" --line-number -M "\n{$threshold}" $(git ls-files "$pattern") || true) \ | |
| cut -d ":" -f 1,2 \ | |
| tee /dev/tty \ | |
| wc -l) | |
return $(( count < 255 ? count : 255 )) | |
} | |
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | |
main "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment