+progress_update()
+{
+ test -t 1 || return 0 # suppress progress meter if non-interactive
+ this="$1"
+ first="$2"
+ last="$3"
+ range="$(expr $last - $first ||:)"
+ prog="$(expr $this - $first ||:)"
+ # this automatically rounds to nearest integer
+ perc="$(expr 100 \* $prog / $range ||:)"
+ # note \r so next update will overwrite
+ printf "%3d%%\r" $perc
+}
+
+progress_done()
+{
+ test -t 1 || return 0 # suppress progress meter if non-interactive
+ printf "100%%\n"
+}
+
+
+#### Replace generated Content-ID headers with static value
+replace_contentid()
+{
+ sed "/^Content-ID/s/:.*/: <TESTID>/" "$@"
+}
+
+
+#### Filter that squeezes blank lines, partially emulating GNU cat -s,
+#### but sufficient for our purpose.
+#### From http://www-rohan.sdsu.edu/doc/sed.html, compiled by Eric Pement.
+squeeze_lines()