#!/bin/sh
#
# Wrapper for running OpenXcom.

# Test case-insensitively and pick the first one.
dir=$(find \
	"${HOME}/.openxcom/DATA" \
	"/usr/local/share/openxcom/DATA" \
	-mindepth 1 -maxdepth 1 -iname "geodata" 2>/dev/null | head -n 1)
dir=${dir%/*/*}

if [ -z "$dir" ]; then
	echo "Error: no data available."
	echo "Look in /usr/local/share/doc/pkg-readmes for extra documentation."
	exit 1
fi

cd "$dir" && openxcom-bin "$@"
