I have a OpenVZ Fedora 20 VPS that when I SSH into, my termcap file stored in $XDG_DATA_HOME/terminfo/x/xterm-termite, isn't being read, despite having TERMINFO=$XDG_DATA_HOME/terminfo set. If I execute a subshell bash it works fine. Or if I add exec bash to the end of my .profile it works fine.

I saw this question and suspected it could be the same thing. But I'm logging in with the /usr/bin version bash already anyway

$ echo $BASH
$ which bash

I also tried Ubuntu 13.10 on the VPS and saw the same problem.

Patrick's question did get me thinking though, I know the underlying OS of the VPS is REHL. Could that somehow be affecting it?

I source a file called environment in my .profile, which sets the $TERMINFO environment variable if the terminfo directory exists in XDG_DATA_HOME.

$ echo $TERMINFO
$ find $TERMINFO
$ echo $TERM

This works fine on my Linode VPS.

  • Where is this being set? In what file? How are they being set? Show us the exact line. What do echo $TERMINFO and echo $XDG_DATA_HOME return?
    – terdon
    May 18 '14 at 19:20
  • I updated the question with that output and then some :) May 18 '14 at 21:36

Bash loads the terminfo database entry only when it starts (like most programs) or when you change the TERM variable. Changing the TERMINFO variable has no immediate effect: it is only used when the terminfo entry is loaded, it doesn't trigger a reload.

When you run exec bash, this starts a new instance of bash which loads the terminal entry based on the current values of TERM and TERMINFO.

You can reload the terminfo database by assigning to TERM. Bash optimizes TERM=$TERM, it doesn't reload the data, so you'll need to go via an intermediate value.

# Reload the terminfo entry to take the new value of $TERMINFO into account
old_TERM=$TERM; TERM=dumb; TERM=$old_TERM; unset old_TERM
  • You're right, that does indeed work. (even shorter: TERM=${TERM}X; TERM=${TERM:0:-1}). Can you explain why I don't see this behaviour (of not reading the TERMINFO on start) in some of my other machines where I have it setup the same way, particular on a Arch Linux box (Bash 4.3.11), and a Ubuntu Linode VPS (Bash 2.2.37)? (The box where it isn't working is Bash 4.2.47) May 19 '14 at 9:55
  • Also, just doing TERM=$TERM does seem to work :) May 19 '14 at 9:56
  • Spoke too soon :( this works when entering this from the prompt after just logging in. But adding this at the end of my .profile does not work. May 19 '14 at 10:12
  • @EvanPurkhiser Did you try with the code I provided (and not just TERM=$TERM? I can't see why it wouldn't work from .profile. Make sure you have strace installed and add sh -c "strace -p $$ -e file -o ~/bash.login.strace & :" to .profile before the lines that manipulate TERM or TERMINFO. The file bash.login.strace will contain a trace of the files that the login shell accesses after that point, post that trace. May 19 '14 at 22:43
  • I did use the code you provided. Here's a snippet of my .profile and here's the strace. Also, here is a strace of one of my servers that works fine without having to do any special TERM hackery. May 20 '14 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.