#!/bin/bash

echo "Tests that all files are parseable by p*totext,"
echo "in order to suport dhelp integration."

set -e
shopt -s nullglob

cd /usr/share/doc/RFC/links

for i in *.ps; do
  echo " - testing $i"
  pstotext $i > /dev/null
done

for i in *.ps.gz; do
  echo " - testing $i"
  zcat $i | pstotext > /dev/null
done

for i in *.pdf; do
  echo " - testing $i"
  pdftotext $i > /dev/null
done

TMP="$(mktemp)" || exit 1
trap "rm -f '$TMP'" EXIT

for i in *.pdf.gz; do
  echo " - testing $i"
  zcat $i > "$TMP"
  pdftotext "$TMP" >/dev/null
done

rm -f "$TMP"
trap - EXIT
