#!/bin/sh
set -f
preload="%%PREFIX%%/lib/libloadplay.so"
preload="${0%/*}/obj/libloadplay.so" #RM
while [ "${1#-}" != "$1" ]; do
	case "$1" in
	-h | --help)
		/bin/cat 1>&2 << USAGE
usage: loadplay [-h] [-i file] [-o file] command ...

        -h, --help          Show usage and exit
        -i, --input   file  Input from file
        -o, --output  file  Output to file
USAGE
		return 0
	;;
	-i | --input)
		exec <"$2"
		shift 2
	;;
	-i*)
		exec <"${1#-i}"
		shift
	;;
	-o | --output)
		exec >"$2"
		shift 2
	;;
	-o*)
		exec >"${1#-o}"
		shift
	;;
	- | -? | --*)
		echo "loadplay: unknown option: $1" >&2
		"$0" --help
		return 1
	;;
	-?*)
		arg="$1"
		shift
		set -- "${arg%%${arg#-?}}" "-${arg#-?}" "$@"
	;;
	esac
done
if [ -z "$1" ]; then
	echo "loadplay: command missing" >&2
	"$0" --help
	return 1
fi
exec /usr/bin/env LD_PRELOAD="$preload" "$@"

#!/bin/sh
set -f
preload="%%PREFIX%%/lib/libloadplay.so"
preload="${0%/*}/obj/libloadplay.so" #RM
while [ "${1#-}" != "$1" ]; do
	case "$1" in
	-h | --help)
		/bin/cat 1>&2 << USAGE
usage: loadplay [-h] [-i file] [-o file] command ...

        -h, --help          Show usage and exit
        -i, --input   file  Input from file
        -o, --output  file  Output to file
USAGE
		return 0
	;;
	-i | --input)
		export LOADPLAY_IN="$2"
		shift 2
	;;
	-i*)
		export LOADPLAY_IN="${1#-i}"
		shift
	;;
	-o | --output)
		export LOADPLAY_OUT="$2"
		shift 2
	;;
	-o*)
		export LOADPLAY_OUT="${1#-o}"
		shift
	;;
	- | -? | --*)
		echo "loadplay: unknown option: $1" >&2
		"$0" --help
		return 1
	;;
	-?*)
		arg="$1"
		shift
		set -- "${arg%%${arg#-?}}" "-${arg#-?}" "$@"
	;;
	esac
done
if [ -z "$1" ]; then
	echo "loadplay: command missing" >&2
	"$0" --help
	return 1
fi
exec /usr/bin/env LD_PRELOAD="$preload" "$@"

Set LOADPLAY_IN/OUT instead of changing stdin/out
Set LOADPLAY_IN/OUT instead of changing stdin/out

This change allows separating output from the host process and
libloadplay.so.
