#!/bin/bash
x11_app=X11
if [ -d /Applications/Utilities/X11.app ]; then
x11_app=/Applications/Utilities/X11.app
elif [ -d /Applications/X11.app ]; then
x11_app=/Applications/X11.app
fi
for d in /usr/X11R6/bin /usr/bin/X11 /usr/local/bin/X11; do
if [ -d $d ]; then
case $PATH in
'')
PATH=$d
;;
$d|$d:*|*:$d|*:$d:*)
: do nothing
;;
*)
PATH=$PATH:$d
;;
esac
fi
done
while [ $ app="$1"; shift
if [ ! -f "$app" ]; then
real_app=`type -p "$app"`
if [ -z "$real_app" ]; then
echo "$1: unknown application: $app"; exit 1
fi
app="$real_app"
fi
/usr/bin/open -a "$x11_app" "$app"
done