summaryrefslogtreecommitdiff
path: root/jh-checksource.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-10-10 22:11:40 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-10-10 22:11:40 -0400
commit86b94bc3ad4d4594647d3b09b15457b71732252f (patch)
tree2fc32513f0a6e7e19c24b99f81499e583586fdb7 /jh-checksource.sh
parentd404068c910c9a953e281d3c8ac62af77e3cac24 (diff)
fix problems with jh-checksource
Diffstat (limited to 'jh-checksource.sh')
-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:"