bugGNU Screen - Bugs: bug #48848, ignoring -T parameter


bug #48848: ignoring -T parameter

Submitter:  Josef Ridky <jridky>
Submitted:  Mon 22 Aug 2016 07:16:38 AM UTC
Category:  None Severity:  3 - Normal
Priority:  * 5 - Normal Status:  Confirmed
Privacy:  Public Assigned to:  None
Open/Closed:  Open Release:  4.4.0
Fixed Release:  None Planned Release:  None
Work Required:  None
* Mandatory Fields

Add a New Comment Rich Markup

Jump to the original submission

Thu 04 Apr 2024 09:27:25 AM UTC, comment #9: 

Still reproducing - at Ubuntu 22.04, 20.04, both for the Ubuntu package and manually built from the same version (4.8.0).

Valentin Nechayev <netch>
Wed 14 Sep 2016 03:54:17 PM UTC, comment #8: 

So I posted why we end up with "screen.xterm" or alike in previous comment.

I think it's more of discussion if we want screen to behave the way it is or force user input.
I would also assume that user input as long as it's correct takes precedence over how it behaves currently, so it should probably first check user passed value and if there is not corresponding termcap proceed with other checks.

And yes, reproduced it:
% echo $TERM
% screen -c /dev/null -T screen
% echo $TERM                  

Amadeusz Sławiński <amade>
Group administrator
Wed 14 Sep 2016 03:42:39 PM UTC, comment #7: 

char *
int aflag;
  char buf[TERMCAP_BUFSIZE];
  register char *p, *cp, *s, ch, *tname;
  int i, wi, he;
#if 0
  int found;

  if (display) ### Check if we are on tty
      wi = D_width;
      he = D_height;
      tname = D_termname; ### here we get value from display (we are on terminal emulator like xterm), tname = "xterm"
      wi = 80;
      he = 24;
      tname = "vt100"; ### here we use vt100, cause we aren't on terminal (for example when running screen from cron job)
  debug1("MakeTermcap(%d)\n", aflag);
  if ((s = getenv("SCREENCAP")) && strlen(s) < TERMCAP_BUFSIZE) ### check for user provided SCREENCAP
      sprintf(Termcap, "TERMCAP=%s", s);
      strcpy(Term, "TERM=screen");         ### Here we just set $TERM to screen
      debug("getenvSCREENCAP o.k.\n");
      return Termcap;
  Termcaplen = 0;
  debug1("MakeTermcap screenterm='%s'\n", screenterm);
  debug1("MakeTermcap termname='%s'\n", tname);
  if (*screenterm == '\0' || strlen(screenterm) > MAXSTR - 3)
      debug("MakeTermcap sets screenterm=screen\n");
      strncpy(screenterm, "screen", MAXTERMLEN);   ### screenterm = "screen"
      screenterm[MAXTERMLEN] = '\0';
#if 0
  found = 1;
      strcpy(Term, "TERM=");  ### here wego and start setting $TERM, it's usual case (ie, we didn't bailout on SCREENCAP check above)
      p = Term + 5;
      if (!aflag && strlen(screenterm) + strlen(tname) < MAXSTR-1)   ### if we are not attaching and we will fit into string
  sprintf(p, "%s.%s", screenterm, tname);  ### screenterm + '.' + tname; assuming above result is "screen.xterm"
  if (e_tgetent(buf, p) == 1)              ### we found terminal entry
    break;                                 ### so we break out of do loop
#ifdef COLOR
      if (nwin_default.bce)
  sprintf(p, "%s-bce", screenterm);
          if (e_tgetent(buf, p) == 1)
      if (wi >= 132)
  sprintf(p, "%s-w", screenterm);
          if (e_tgetent(buf, p) == 1)
      strcpy(p, screenterm);
      if (e_tgetent(buf, p) == 1)
      strcpy(p, "vt100");
#if 0
      found = 0;
  while (0); /* Goto free programming... */

Amadeusz Sławiński <amade>
Group administrator
Wed 14 Sep 2016 02:36:21 PM UTC, comment #6: 


thanks for recommendations.

I have compared termcap.c file from git and from Fedora package and they are identical. I have tried even copy termfiles to ~/.terminfo folder (as you wrote in previous comment) but even now I am not able to set 'screen' string as term variable (so in screen will have TERM variable value 'screen').

I am really confused. Is there some way how to get some debug information?


Josef Ridky <jridky>
Sat 10 Sep 2016 10:16:52 AM UTC, comment #5: 


For analyzing $TERM setting behaviour you want to check lines between 850 and 926 in termcap.c.

One thing I will note that one should be able to copy termfiles to target machine to make it work properly.
Path is ~/.terminfo
For example:
├── r
│   ├── rxvt
│   └── rxvt-unicode
└── s
    ├── screen
    ├── screen-256color
    ├── screen-bce
    ├── screen-s
    ├── st
    ├── st-256color
    ├── st-meta
    └── st-meta-256color

Amadeusz Sławiński <amade>
Group administrator
Mon 05 Sep 2016 10:28:51 AM UTC, comment #4: 


I have found something interesting,
in Fedora (but I don't know, if only there or if is this presented even on other OS) we are not able to set terminal type to 'screen' only using -T parameter. Any other terminal value can be set without any problems.

Unfortunately, there is probably presented some heuristic (that is used for setting vt100 terminal type in case of nonsense terminal type is setted as -T parameter), which caused this issue. I am just don't know, if this heuristic is done by screen package or any other system service.

Any ideas?


Josef Ridky <jridky>
Mon 22 Aug 2016 01:54:48 PM UTC, comment #3: 

Hi again,

I have tried the screen version from git master branch.
Unfortunately, described problem persists for me.

I will compare screen package from Fedora with upstream version (4.4.0), just to find, if there wasn't problem with upgrade in Fedora.

If anybody have idea, where I should start, please leave comment here.



Josef Ridky <jridky>
Mon 22 Aug 2016 11:59:38 AM UTC, comment #2: 


I am using Fedora 24 64-bit, but unfortunately, this is my current output:

~$ echo $TERM
~$ screen -T "screen"
~$ echo $TERM

Second echo is used in screen window.

I will try it in git-master version of screen and I will let you know.


Josef Ridky <jridky>
Mon 22 Aug 2016 11:44:22 AM UTC, comment #1: 

Hey Josef,
thank you for submitting bugreport.

Unfortunately, I should say I can't reproduce it...
I can change my $TERM via -T or ~/.screenrc in v4.4.0 and git-master version.

Which OS do you use? Can you try git-version?

Alexander Naumov <anaumov>
Group administrator
Mon 22 Aug 2016 07:16:38 AM UTC, original submission:  

screen ignores the terminal type setting, either via the command line option -T or via the .screenrc setting "term".  It always sets TERM=screen.xterm-256color, but this is incompatible when SSH-ing into older systems that don't have that terminal type defined.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. screen -T screen
2. edit .screenrc, set "term screen"

Actual results:

>env|grep TERM


Expected results:

>env|grep TERM


Josef Ridky <jridky>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by netch (Posted a comment)
  • -email is unavailable- added by amade (Posted a comment)
  • -email is unavailable- added by anaumov (Posted a comment)
  • -email is unavailable- added by jridky (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-09-14 amade StatusWorks For Me Confirmed
    2016-08-22 anaumov StatusNone Works For Me

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code