summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jh-checksource.sh19
1 files 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='<nofileevercontainsthis>'
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:"