--- xrsh-5.92.orig/xrsh.sh
+++ xrsh-5.92/xrsh.sh
@@ -20,7 +20,8 @@
 #
 # xrsh:  start an X11 client on another host
 #
-# Usage: xrsh [-help] [-version ] [-l username] [-auth authtype] [-screen #] [-pass envlist] \
+# Usage: xrsh [-help] [-version ] [-l username] [-e rshprog] \
+#	[-auth authtype] [-screen #] [-pass envlist] \
 #	[-debug] [-debug2] hostname [X-command [arguments...]]
 #
 # Example usage: xrsh expo.lcs.mit.edu xterm
@@ -37,6 +38,7 @@
 #       executed by the script  (very verbose)
 #    The -l switch allows you to use a different login name on the
 #       remote host.  -l and its argument are passed directly to rsh.
+#    Using -e you can set another rsh program to use, e.g. ssh.
 #    The -help switch prints out the usage message.
 #    The -screen switch allows you to start a client on a different screen.
 #    If no X command is given, it defaults to xterm.  This means that
@@ -70,6 +72,9 @@
 #        because it will expand to ~ on the local host, but try to put the
 #        errors in that file on the remote host.)    
 #
+#    The environment variable XRSH_RSH sets the rsh program to use to access
+#        the remote site. Default is remsh or rsh. 
+#
 #
 #  COMMON PROBLEMS:
 #     * Make sure your PATH environment variable on the remote host is
@@ -122,7 +127,7 @@
 rshoptions=""
 passenvs=                # environment variables to pass along
 xhostvar=                # used by auth type xhost-xterminal
-usage="usage: $progname [-help] [-version] [-l username] [-auth authtype] [-screen #] [-debug] [-debug2] host [cmd [args ...]]"
+usage="usage: $progname [-help] [-version] [-l username] [-e rshprog] [-auth authtype] [-screen #] [-debug] [-debug2] host [cmd [args ...]]"
 
 if [ -z "$DISPLAY" ]; then
     echo "$progname: "'$DISPLAY must be set' 1>&2 ;
@@ -156,6 +161,9 @@
         -l)
             shift; rshoptions="-l $1"; foundarg=yes; shift;
             ;;
+        -e)
+            shift; XRSH_RSH="$1"; foundarg=yes; shift;
+            ;;
 	-auth)
             shift; XRSH_AUTH_TYPE=$1; foundarg=yes; shift;
             ;;
@@ -213,11 +221,11 @@
 oldIFS=$IFS
 IFS=:
 set  $DISPLAY
+IFS=$oldIFS
 case "$#" in
     1) displayhost=$localhost;;
     *) displayhost=$1;;
 esac
-IFS=$oldIFS
 
 case "$displayhost" in
     "unix"|"local"|"")
@@ -233,11 +241,15 @@
     command="$command $xcmdargs"
 fi
 
+if [ "$XRSH_RSH" ]; then
+    rsh="$XRSH_RSH"
 # Some System V hosts have rsh as "restricted shell" and ucb rsh is remsh
-if [ -r /usr/bin/remsh ]; then
-    rsh=remsh
-elif [ -f /usr/bin/rcmd ]; then       # SCO Unix uses "rcmd" instead of rsh
-    rsh=rcmd
+elif [ -x /usr/bin/ssh ]; then
+    rsh=/usr/bin/ssh
+elif [ -x /usr/bin/remsh ]; then
+    rsh=/usr/bin/remsh
+elif [ -x /usr/bin/rcmd ]; then       # SCO Unix uses "rcmd" instead of rsh
+    rsh=/usr/bin/rcmd
 else
     rsh=rsh
 fi
@@ -250,6 +262,7 @@
 oldIFS=$IFS
 IFS=:
 set  $DISPLAY
+IFS=$oldIFS
 if [ $# = 2 ]; then 
     shift
 fi
@@ -285,7 +298,6 @@
         newdisplay="${displayhost}:$@"
         ;;
 esac
-IFS=$oldIFS
 
 # process env variables to pass early so that we can send them 
 # in the xauth commands as well as the actual X client rsh command.
