From 86b94bc3ad4d4594647d3b09b15457b71732252f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 10 Oct 2012 22:11:40 -0400 Subject: fix problems with jh-checksource --- jh-checksource.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/jh-checksource.sh b/jh-checksource.sh index 101a187..a0e98bb 100644 --- a/jh-checksource.sh +++ b/jh-checksource.sh @@ -3,7 +3,7 @@ sep='' resep='@' -safe_patterns=( +safe_types=( '.*text.*' '(GIF|JPEG|PNG) image data.*' ) @@ -11,24 +11,29 @@ safe_files=("$@") unsafe_files="$(mktemp)" +safevar="$(`mktemp`)" find . -type f -exec file -F"$sep" {} + | while read line; do file="$(echo "$line"|sed "s${resep}${sep}.*${resep}${resep}")" type="$(echo "$line"|sed "s${resep}.*${sep}\s*${resep}${resep}")" - safe=false + echo false > "$safevar" + if [[ "$file" =~ ".*/\.git/.*" ]]; then + echo true > "$safevar" + fi for filename in "${safe_files[@]}"; do if [[ "$file" = "$filename" ]]; then - safe=true; + echo true > "$safevar" fi done - for pattern in "${safe_patterns[@]}"; do - if [[ "$type" =~ "$pattern" ]]; then - safe=true; + for filetype in "${safe_types[@]}"; do + if [[ "$type" =~ "$filetype" ]]; then + echo true > "$safevar" fi done - if ! $safe; then + if [[ "$(cat "$safevar")" = 'true' ]]; then printf "%s\n" "$file" fi done > "$unsafe_files" +rm -f "$safevar" if [[ -n "$(cat "$unsafe_files")" ]]; then echo " ==> The source directory `pwd` contains binary files:" -- cgit v1.2.3-54-g00ecf