#!/bin/sh

if ! test -f bin/prelude; then
	cat "$1" > "$2" && chmod +x "$2";
	exit;
fi

{
	read
	printf '#!%s\n' "$(cat bin/interpreter)"
	while read line; do
		if test "$line" = "## PRELUDE_PLACEHOLDER ##"; then
			cat bin/prelude
			break
		else
			printf '%s\n' "$line"
		fi
	done
	cat
} < "$1" > "$2" && chmod +x "$2"
