Skip to content

Commit

Permalink
Bugfix: All temporary files are now automatically removed. This closes
Browse files Browse the repository at this point in the history
  • Loading branch information
tokee committed Oct 23, 2014
1 parent 037e563 commit 77b9ff9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions analyze.sh
Expand Up @@ -44,7 +44,7 @@ function im_identify() {
fi
if [ "false" == "$ASSUME_GREY" ]; then
# We do the TIFF-conversion to force greyscale
local TMP=`mktemp`.tif
local TMP=`mktemp --suffix .tif`
if [ "." == ".$CROP_PERCENT" ]; then
gm convert "$SRC" -colorspace gray "$TMP"
else
Expand All @@ -56,10 +56,10 @@ function im_identify() {
if [ "." == ".$CROP_PERCENT" ]; then
identify -verbose "$SRC" > "$IDENTIFY"
else
local TMP=`mktemp`.tif
local TMP=`mktemp --suffix .tif`
gm convert "$SRC" -gravity Center -crop $CROP_PERCENT%x+0+0 "$TMP"
identify -verbose "$TMP" > "$IDENTIFY"
#rm "$TMP"
rm "$TMP"
fi
fi
echo "$IDENTIFY"
Expand Down Expand Up @@ -273,7 +273,7 @@ function histogramScript() {
# We create a PGM-file with the extracted greyscale statistics
# as a histogram. The PGM is sideways because it is easier
# http://netpbm.sourceforge.net/doc/pgm.html
local HTMP=`mktemp`.pgm
local HTMP=`mktemp --suffix .pgm`
if [ "true" == "$LOG" ]; then
local NONE=1
else
Expand Down Expand Up @@ -317,7 +317,7 @@ function histogramScript() {
# echo "convert $HTMP -rotate 270 $DEST"
convert $HTMP -rotate 270 "$DEST"
# ls -l $HTMP
# rm $HTMP
rm $HTMP
}
export -f histogramScript

Expand Down
2 changes: 1 addition & 1 deletion greyscale_stats.sh
Expand Up @@ -12,7 +12,7 @@
# Input: A greyscale image
# Output: Name pixel_count unique_greyscales #darkest_pixels darkest_pixels_percent darkest_greyscale #brightest_pixels brightest_pixels_percent lightest_greyscale

TMP="/tmp/tmp_crop.bmp"
TMP="`mktemp --suffix .bmp`"

if [ "." == ".$1" ]; then
echo "Usage: filename [croppercent]"
Expand Down
11 changes: 6 additions & 5 deletions quack.sh
Expand Up @@ -381,7 +381,7 @@ function copyFiles () {
# http://stackoverflow.com/questions/14434549/how-to-expand-shell-variables-in-a-text-file
# Input: template-file
function ctemplate() {
TMP="`mktemp`.sh"
local TMP="`mktemp --suffix .sh`"
echo 'cat <<END_OF_TEXT' > $TMP
cat "$1" >> $TMP
echo 'END_OF_TEXT' >> $TMP
Expand Down Expand Up @@ -772,13 +772,14 @@ function makeIndex() {
else
EDITION_HTML=""
for E in *.Edition.xml; do
local EDTMP=`mktemp`
# echo to get newlines
EDITION_HTML="${EDITION_HTML}<p>$E</p>"$'\n'
EDITION_HTML="${EDITION_HTML}<pre>"$'\n'
cat $E | sed -e 's/&/&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g' -e 's/"/\&quot;/g' -e 's/\&gt;\([^\&]\+\)\&lt;/\&gt;<span class="xmlvalue">\1<\/span>\&lt;/g' > /tmp/t_edition
# cat $E | sed -e 's/&/&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g' -e 's/"/\&quot;/g' -e 's/\&lt;([^\&]+)\&gt;/\&lt;<span class="xmlvalue">\1</span>\&gt;/g' > /tmp/t_edition
EDITION_HTML="${EDITION_HTML}`cat /tmp/t_edition`"$'\n'
rm /tmp/t_edition
cat $E | sed -e 's/&/&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g' -e 's/"/\&quot;/g' -e 's/\&gt;\([^\&]\+\)\&lt;/\&gt;<span class="xmlvalue">\1<\/span>\&lt;/g' > $EDTEMP
# cat $E | sed -e 's/&/&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g' -e 's/"/\&quot;/g' -e 's/\&lt;([^\&]+)\&gt;/\&lt;<span class="xmlvalue">\1</span>\&gt;/g' > $EDTEMP
EDITION_HTML="${EDITION_HTML}`cat $EDTEMP`"$'\n'
rm $EDTEMP
EDITION_HTML="${EDITION_HTML}</pre>"$'\n'
done
fi
Expand Down
2 changes: 1 addition & 1 deletion quack_helper_imagepage.sh
Expand Up @@ -10,7 +10,7 @@ popd > /dev/null
# http://stackoverflow.com/questions/14434549/how-to-expand-shell-variables-in-a-text-file
# Input: template-file
function ctemplate() {
TMP="`mktemp`.sh"
local TMP=`mktemp --suffix .sh`
echo 'cat <<END_OF_TEXT' > $TMP
cat "$1" >> $TMP
echo 'END_OF_TEXT' >> $TMP
Expand Down

0 comments on commit 77b9ff9

Please sign in to comment.