#!/bin/sh
## Extracts the data fork from a file in Mac binhex format.
## Mostly a wrapper to civilize the xbin program for inclusion
## in mailcap lines.  -- lcs oct 97
##
## Usage: unbinhex  <in>  [ <out> ]
## ...where in can be '-' for stdin.
## Writes the DATA fork only to the output file (or stdout if none spec.)
## KLUDGE: xbin gives bogus return value.
## $Id: unbinhex,v 1.1 1998/03/17 23:43:22 lcs Exp $
set -e

xbin="/afs/athena/contrib/consult/bin/xbin"
xbinopt=

tmpdir="/tmp"
tmpfile="UBH$$"
tmp="${tmpdir}/$tmpfile"
( chdir $tmpdir ; $xbin -n $tmpfile $xbinopt $1 || true )
if [ "$2" = '' ]; then
    cat ${tmp}.data
else
    cp ${tmp}.data $2
fi
rm -f ${tmp}.data ${tmp}.info ${tmp}.rsrc
exit 0
