#!/bin/sh
# Usage: dpr [-P<printer>] [<filename>...]
# Prints the document in duplex (long bind)
# Can be overridden by the document, so does work as expected only if
# the document doesn't specify any duplex preferences
if echo "x$1" | grep "^x-P" > /dev/null; then
  flags="$1"
  shift
fi
(
  echo "%!"
  echo "<</Duplex true /Tumble false>> setpagedevice"
  cat "$@"
) | lpr $flags
