github.com/anchore/syft@v1.38.2/.github/scripts/check_binary_fixture_size.sh (about) 1 #!/bin/bash 2 3 # current limit for fixture size 4 size=1000 5 6 if [ $# -eq 0 ]; then 7 echo "Usage: $0 <directory>" 8 exit 1 9 fi 10 11 directory="$1" 12 13 # Remove trailing slash using parameter expansion 14 directory="${directory%/}" 15 16 if [ ! -d "$directory" ]; then 17 echo "Directory not found: $directory" 18 exit 1 19 fi 20 21 found_large_files=0 22 while IFS= read -r -d '' file; do 23 if [ $(wc -c < "$file") -gt $size ]; then 24 echo "File $file is greater than ${size} bytes." 25 found_large_files=1 26 fi 27 done < <(git ls-files -z "$directory") 28 29 if [ "$found_large_files" -eq 1 ]; then 30 echo "Script failed: Some files are greater than ${size} bytes." 31 exit 1 32 else 33 echo "All files in $directory and its subdirectories are ${size} bytes or smaller. Check passed." 34 exit 0 35 fi 36