#!/bin/bash

x=''

help=''
args=''
argc=0
while [ $# -gt 0 ]; do
	case $1 in
		--x|-x)		x='1';;
		--help|-h)	help='1';;
		*)		args="$args $1"; argc=$(($argc+1));;
	esac
	shift
done
set -- $args

usage () {
	echo "Usage: $(basename $0) [-x] [{target}]"
}

if [ -n "$1" ]; then
	target=$1
	shift
fi

[ $# -gt 0 ] && help='1'

if [ $help ]; then
	usage
	exit 1
fi

if [ ! -e ~/$target/.dosemurc ]; then
	echo "Wrong target!"
	exit 1
fi

if [ -n "$x" ]; then
	prg=/usr/bin/xdos
	[ -x $prg ] || prg=/usr/bin/xdosemu
else
	prg=/usr/bin/dos
	[ -x $prg ] || prg=/usr/bin/dosemu.bin
fi

$prg -f ~/$target/.dosemurc