#!/bin/sh

if test $# -ne 1 -a $# -ne 2; then
	echo usage: mprfilter prog [filename] >&2
	exit 1
fi

if test $# -eq 1; then
	MPRFILTER=cat
else
	if test ! -r $2; then
		echo $1: $2 is not readable >&2
		exit 1
	fi
	if file $2 | grep compress >/dev/null 2>&1; then
		MPRFILTER="gzip -dc $2"
	else
		MPRFILTER="cat $2"
	fi
fi

echo $MPRFILTER
exit 0
