#!/bin/sh

if [ "$1" = "-e" ]; then
	if [ -n "$2" ]; then
		shift
		ESTRING="$@"
	else
		shift
	fi
fi	

if [ -d "$*" ]; then
	cd "$*"
elif [ -x "$*" ]; then
	cd `dirname "$*"`
	ESTRING="`which pauseme`"
	MSTRING="$*"
elif [ -f "$*" ]; then
	ESTRING="`which less`"
	MSTRING="$*"
elif [ "`echo $* | grep "http:/"`" -o "`echo $* | grep "ftp:"`" ]; then
	# This requires lynx or links. If you don't have it, don't drop URLs.
	if which lynx >/dev/null 2>&1; then
		ESTRING="`which lynx`"
	elif which links >/dev/null 2>&1; then
		ESTRING="`which links`"
	fi
	MSTRING="$*"
fi

if [ x"$ESTRING" = x"" ]; then
	exec exo-open --launch TerminalEmulator
elif [ x"$MSTRING" = x"" ]; then
	exec exo-open --launch TerminalEmulator $EXEC"$ESTRING"
else
	exec exo-open --launch TerminalEmulator $EXEC"$ESTRING" "$MSTRING"
fi

exit 0			
