#!/bin/bash

echo "Tests that all files are parseable by p*t*xt,"
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"
  ps2txt $i > /dev/null
done

for i in *.ps.gz; do
  echo " - testing $i"
  zcat $i | ps2txt > /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
