#! /bin/bash

if [ "$#" -gt 0 ]; then
  eps=${1}
  base=$(basename ${eps} .eps)
  dirty="${base}.dirty.hpgl"
  clean="${base}.hpgl"

  pstoedit -f plot-hpgl "${eps}" "${dirty}"
  # Clean HPGL
  ./hpgl-distiller -i "${dirty}" -o "${clean}"
  rm "${dirty}"
else
  echo "Usage: eps2hpgl.sh [epsfile]"
  echo "Converts eps file to hpgl description"
fi