# read stdin into temp file; run args on file; write file to stdout
pee() (
  test "$#" -eq 0 && set -- cat
  temp=
  trap '\rm -f -- "$temp"' EXIT
  temp="$(mktemp)"
  test -n "$temp" && test -w "$temp" && test -r "$temp" || {
    rm "$temp" 2>/dev/null
    return 1
  }
  cat >"$temp" && "$@" "$temp" <>/dev/tty >&0 2>&0 && cat "$temp"
)
