diff options
author | Jonas Smedegaard <dr@jones.dk> | 2008-03-17 13:06:44 +0000 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2008-03-17 13:06:44 +0000 |
commit | 7eaf1da5f71d019de5b82c6a3e682ca50910c69c (patch) | |
tree | 5fba9ffd4ddcb61e2e3386fbc0cceb00355a23db | |
parent | b85e717cea722198254d13478496b26d85bc641a (diff) |
Fix resolving infile and outfile. More compact option resolving.
-rwxr-xr-x | localpdf2pdfscreen | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/localpdf2pdfscreen b/localpdf2pdfscreen index 3d2095d..2fd90a1 100755 --- a/localpdf2pdfscreen +++ b/localpdf2pdfscreen @@ -3,7 +3,7 @@ # /usr/local/bin/localpdf2pdfscreen # Copyright 2008 Jonas Smedegaard <dr@jones.dk> # -# $Id: localpdf2pdfscreen,v 1.2 2008-03-17 12:53:04 jonas Exp $ +# $Id: localpdf2pdfscreen,v 1.3 2008-03-17 13:06:44 jonas Exp $ # # Downsize PDF file. # @@ -37,6 +37,8 @@ exit1() { [ $# -gt 0 ] || exit1 "Input file missing" +infile= +outfile= pdftopsopts= pstopdfopts= while [ $# -gt 0 ]; do @@ -54,24 +56,29 @@ while [ $# -gt 0 ]; do shift ;; *) - pools="$pools $1" + if [ -z "$infile" ]; then + infile="$1" + elif [ -z "$outfile" ]: then + outfile="$1" ] + else + exit1 "Too many parameters" + fi shift ;; esac done ps2pdfopts="$@" -# Use default options if none provided -[ -n "pdftopsopts" ] || pdftopsopts="$PDFTOPSOPTS" -[ -n "ps2pdfopts" ] || ps2pdfopts="$PS2PDFOPTS" - -infile="$1" -tmpfile=$(mktemp -t "$PRG.XXXXXXXXXX") || exit 1 -outfile="${2:-$infile.pdf}" +# Use defaults if not overridden +outfile="${outfile:-$infile.pdf}" +pdftopsopts="${pdftopsopts:-$PDFTOPSOPTS}" +ps2pdfopts="${ps2pdfopts:-$PS2PDFOPTS}" [ ! -e "$outfile" ] || exit1 "Output file already exists" -pdftops $pdftopsopts "$infile" "$tmpfile" +tmpfile=$(mktemp -t "$PRG.XXXXXXXXXX") || exit 1 + +pdftops $pdftopsopts "$infile" "$tmpfile" || rm "$tmpfile" ps2pdf $ps2pdfopts "$tmpfile" "$outfile" rm "$tmpfile" |