| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | # Revised in 2020 to use the eps2write device (within ps2epsi.ps) |
| 4 | |
| 5 | # This definition is changed on install to match the |
| 6 | # executable name set in the makefile, but we check a couple of other |
| 7 | # places (bin/ sibling to $LIBDIR and 'gs' on the $PATH) |
| 8 | GS_EXECUTABLE=gs |
| 9 | LIBDIR=`dirnamescip-shell system . . dirname. $0` |
| 10 | gs="$LIBDIR/$GS_EXECUTABLE" |
| 11 | if testscip-shell system . . test. ! -x "$gs"; then |
| 12 | # Might be executing lib/ps2epsi with bin/ as sibling to lib/ |
| 13 | gs="$LIBDIR/../bin/$GS_EXECUTABLE" |
| 14 | if testscip-shell system . . test. ! -x "$gs"; then |
| 15 | # Fallback to using any 'gs' on the path |
| 16 | gs="$GS_EXECUTABLE" |
| 17 | fi |
| 18 | fi |
| 19 | GS_EXECUTABLE="$gs" |
| 20 | |
| 21 | export outfile |
| 22 | |
| 23 | if [scip-shell system . . `[`. $# -lt 1 -o $# -gt 2 ]; then |
| 24 | echoscip-shell system . . echo. "Usage: `basenamescip-shell system . . basename. \"$0\"` file.ps [file.epsi]" 1>&2 |
| 25 | exit 1 |
| 26 | fi |
| 27 | |
| 28 | infile=$1; |
| 29 | |
| 30 | if [scip-shell system . . `[`. $# -eq 1 ]; then |
| 31 | case "${infile}" in |
| 32 | *.ps) base=`basenamescip-shell system . . basename. "${infile}" .ps` ;; |
| 33 | *.cps) base=`basenamescip-shell system . . basename. "${infile}" .cps` ;; |
| 34 | *.eps) base=`basenamescip-shell system . . basename. "${infile}" .eps` ;; |
| 35 | *.epsf) base=`basenamescip-shell system . . basename. "${infile}" .epsf` ;; |
| 36 | *) base=`basenamescip-shell system . . basename. "${infile}"` ;; |
| 37 | esac |
| 38 | outfile=${base}.epsi |
| 39 | else |
| 40 | outfile=$2 |
| 41 | fi |
| 42 | |
| 43 | # Note, we expect 'ps2epsi.ps' to be on one of the search paths which can be seen by: gs -h |
| 44 | "$GS_EXECUTABLE" -q -dNOOUTERSAVE -dNODISPLAY -dLastPage=1 -sOutputFile="${outfile}" \ |
| 45 | --permit-file-all="${infile}" --permit-devices="eps2write:bit" -- ps2epsi.ps "${infile}" 1>&2 |
| 46 | |
| 47 | exit 0 |