Solaris and Linux xterm terminfo differences

This problem might well be well-known to hardcore UNIX people but it had me scratching me head for a bit today so I thought I’d post about it together with my workaround.

I sometimes have cause to use a terminal-based application installed on servers running Solaris 9 that uses function keys F1F4 to navigate its internal menus. In the past I’ve accessed these from a Windows XP laptop using Putty, but recently I’ve started using a Linux machine running Xubuntu. Today I came to try and use this particular application from the Linux box but (leaving aside the fact that the F1 key is reserved for the Help system in Xubuntu’s terminal app) the function keys merely echoed back 0Q, 0R and 0S rather than performing the desired menu operations.

This made me think it was a terminfo related problem and a bit of Googling confirmed that this was most likely the root cause. I did some comparisons of the output of infocmp on both systems and it turns out that the terminfo definition for xterm used on Solaris 9 differs considerably from that on Linux in a number of ways. Specific to my problem, the sequences defined for F1F4 on Solaris 9 are different from those on Linux as follows:

Key Solaris 9 Linux
F1 \E[11~ \E0P
F2 \E[12~ \E0Q
F3 \E[13~ \E0R
F4 \E[14~ \E0S

I could see three obvious ways of dealing with this problem.

  1. Distribute an updated xterm terminfo definition to one set of machines.
  2. Create a custom terminfo definition, distribute it to all the machines and use it when ssh’ing between them.
  3. Locate an exisiting terminfo definition already shared by the machines that meets the immediate requirements.

The disadvantages of (1) include possibly breaking other things that rely on the exisiting definitions and also the fact that system policy might prevent changing this kind of setting to meet an individual’s requirement. (2) Might be a bit more promising but it means spending the time creating the definition and also assumes no issues with system policy as implied above. (3) is the path of least resisitance.

In fact (3) is the solution I currently use. The vt220 definitions are similar enough and match on the all-important function key definitions, so I’m currently setting $TERM to this value before ssh’ing from my Linux box to the Solaris servers.