[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Transmitting the charset (from the locales / LC_CTYPE) over ssh



On 2004-03-29 15:15:40 +0100, Colin Watson wrote:
> On Mon, Mar 29, 2004 at 03:44:57PM +0200, Vincent Lefevre wrote:
> > I think there's still the TERM hack (I used to do that with rlogin
> > in the past, to transmit the DISPLAY via the TERM variable). But I
> > really don't want to use that if there is a better way.
> 
> Can you elaborate?

I used to pass the DISPLAY information to the remote side by
rewriting TERM to contain the real TERM value, followed by a
separator, followed by the DISPLAY value. On the remote side,
TERM was decoded by the .zshenv or .cshrc (depending on the
shell) to set TERM and DISPLAY to the correct values. Here's
my zsh script dlogin that does this:

# Usage: dlogin [-] [opts] host

# TERM is rewritten $TERM^$DISPLAY (a / as a separator instead of ^ would
# be simpler, but the /* part is stripped by rlogin, so this doesn't work).

# The .zshenv on host should contain:
#   if [[ $TERM == *^* ]] then
#     export DISPLAY=${TERM#*\^}
#     export TERM=${TERM%\^*}
#   fi

# The .cshrc on host should contain:
#   if ($?TERM) then
#     if ("$TERM" =~ *^*) then
#       setenv DISPLAY $TERM:s#^#/#:t
#       setenv TERM $TERM:s#^#/#:h
#     endif
#   endif

emulate -LR zsh
local xauth display exec

if [[ $1 == - ]] then
  shift
  xauth=1
fi

if [[ $# -eq 0 ]] then
  echo "usage: dlogin [-] [opts] host"
  return 1
fi

if [[ -n "$DISPLAY" ]] then
  display=${DISPLAY/#:/${HOST}:}
  if [[ -n "$xauth" ]] then
    echo "xauth..."
    xauth extract - $display | rsh $*[-1] xauth merge -
  fi
fi

# exec rlogin if dlogin was started in a subshell
[[ -o interactive ]] || exec=exec
eval $exec env TERM="$TERM${display:+^$display}" rlogin "$@"

> > If terminals could be asked for their locales with an escape
> > sequence, this would be a solution (when being connected to a
> > terminal). Is it possible? If not, could this be added as an
> > extension?
> 
> I've looked and have not found this in any terminal I've looked at.
> 
> One problem is that the remote end may not have the locale you're
> using, so you may want to figure out how to degrade gracefully too
> (which will often just mean falling back to C).

Not much a problem for me.

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA



Reply to: