bugGNU Screen - Bugs: bug #54556, screen is producing invalid...

 
 

bug #54556: screen is producing invalid TERMCAPs

Submitted by:  None
Submitted on:  Wed 22 Aug 2018 09:32:07 PM UTC  
 
Category:  Program Logic Severity:  3 - Normal
Priority:  5 - Normal Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Release:  None
Fixed Release:  None Planned Release:  None
Work Required:  None

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Wed 23 Jan 2019 12:34:35 AM UTC, comment #6: 

The 2-line example after "compile this" should have a tab indenting the second line:

screen.xterm-256color|GNU Screen using 256 colors,
        use=xterm+256color, use=screen

Thomas Dickey <dickey>
Wed 23 Jan 2019 12:31:17 AM UTC, comment #5: 

I see now (wasn't paying attention to the name of the terminal description).  I agree the problem shows up when ncurses can't find the terminfo entry (and while I can see some places to improve ncurses, don't find it likely that Apple will make a timely fix based on my changes).

That's ncurses 5.7 (which you can see by doing a "strings" on the library).  Perhaps the filename was from Apple's initial package (5.4's not relevant).

If ncurses is configured with support for $TERMCAP, that's checked after trying to find a suitable terminfo entry.  screen's formatting a "SC" there because termcap files used to be optimized to use the first two bytes.  ncurses ignores that when reading source, but there's normally no need from an environment variable (since there's only one entry to use).

Apple doesn't provide a screen.xterm-256color (what $TERM was set to), but /usr/bin/tic should be able to compile this (not optimal):

screen.xterm-256color|GNU Screen using 256 colors,                  
        use=xterm+256color, use=screen

and since it has the $HOME/.terminfo feature, it should install the file in that directory by default (if not running as root).  In a quick test, it did that...

The terminfo output from ncurses6.1 will use a value for "pairs" which the older tic will reject (making it "pairs#0"), so the suggested workaround in comment #2 won't be satisfactory.  You could edit the intermediate text file, changing 0x10000 to 0x7fff, and get a better result -- but how much better depends on what the actual terminal emulator is (xterm, Terminal.app and iTerm2 all are different).

Thomas Dickey <dickey>
Tue 22 Jan 2019 05:58:27 PM UTC, comment #4: 

I don't think this affects ncurses6...

If I use the "too-long" TERMCAP below, and edit the terminal-name to something that doesn't have a terminfo entry (say, "yterm"), set TERM=yterm, and then run some apps...

ncurses6 emacs:

emacs: Terminal type yterm is not defined.
If that is not the actual type of terminal you have,
use the Bourne shell command 'TERM=...; export TERM' (C-shell:
'setenv TERM ...') to specify the correct type.  It may be necessary
to do 'unset TERMINFO' (C-shell: 'unsetenv TERMINFO') as well.

ncurses5.4 emacs (/usr/bin/emacs shipped with OSX 10.13):

"TERMCAP", line 1, col 1, terminal 'SC': Missing separator

I'm guessing ncurses6 typically doesn't have a fallback to TERMCAP, but older versions (at least as configured on OSX), do.

If you have a terminfo entry for TERM, then that is used in both cases, and TERMCAP is ignored - and so you won't see an error (screen.xterm-256color isn't in the ncurses5 terminfo database on OSX though...)

Scott Shambarger <sshambar>
Sat 19 Jan 2019 09:04:42 PM UTC, comment #3: 

It would be nice to know how ncurses 6.1 was configured, since
I was unable to reproduce the original report.

Thomas Dickey <dickey>
Tue 15 Jan 2019 11:00:06 PM UTC, comment #2: 

I think I've tracked this down to the TERMCAP variable being larger than the max allowed -- 1023 bytes according to tic(1M).

As a workaround, you need to re-create the terminfo file for screen.xterm-256color using the legacy ncurses5 tic command, and place it in your local ~/.terminfo (since /usr/share/terminfo is protected on OSX).

If you're using (eg ncurses6 on macports), /opt/local/bin/infocmp screen.xterm-256color should give you a nice terminfo source, which you can then compile with the legacy tic, eg:

# /opt/local/bin/infocmp screen.xterm-256color > /tmp/screen.terminfo

# /usr/bin/tic /tmp/screen.terminfo

That will give you a working (local) terminfo file that ncurses5 command-line tools can use over the TERMCAP fallback.

I decided to fix the issue in screen - so that I could use a more modern terminfo file for ncurses6 apps (eg 65536 color pairs, having a local ncurses5 terminfo would limit me to 32767 :), by patching screen to create a valid (<1023 byte) TERMCAP entry.

I've posted my patch in bug #55482 if you want to try it out.

Scott Shambarger <sshambar>
Sat 10 Nov 2018 06:30:18 PM UTC, comment #1: 

Pasting that into a file, the result looks ok and "tic -c" finds no problem.  Line 20 seems to be this:

:F7=\E[15;2~:F8=\E[17;2~:F9=\E[18;2~:FA=\E[19;2~:\

however the error message seems to say that there's some point in
the actual string where there's an "=" without a following ":" before the newline.  Since the pasted text doesn't show it clearly,
you'll have to look for yourself, to clarify this report.

Thomas Dickey <dickey>
Wed 22 Aug 2018 09:32:07 PM UTC, original submission:  

I'm running screen 4.06.02 and ncurses 6.1 on MacOS X.

Screen is creating a TERMCAP variable for my TERM that ncurses can not parse. When I start screen an error message is printed to stderr from ncurses:
"TERMCAP", line 20, col 1, terminal 'SC': Missing separator

This error message happens when my TERM outside of screen is xterm-256color.
Within the screen, my TERM is screen.xterm-256color and screen creates this TERMCAP for it:

SC|screen.xterm-256color|VT 100/ANSI X3.64 virtual terminal:\ :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:bs:bt=\E[Z:\ :cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:ct=\E[3g:\ :do=^J:nd=\E[C:pt:rc=\E8:rs=\Ec:sc=\E7:st=\EH:up=\EM:\ :le=^H:bl=^G:cr=^M:it#8:ho=\E[H:nw=\EE:ta=^I:is=\E)0:\ :li#53:co#234:am:xn:xv:LP:sr=\EM:al=\E[L:AL=\E[%dL:\ :cs=\E[%i%d;%dr:dl=\E[M:DL=\E[%dM:dc=\E[P:DC=\E[%dP:\ :im=\E[4h:ei=\E[4l:mi:IC=\E[%d@:ks=\E[?1h\E=:\ :ke=\E[?1l\E>:vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l:\ :ti=\E[?1049h:te=\E[?1049l:us=\E[4m:ue=\E[24m:so=\E[3m:\ :se=\E[23m:mb=\E[5m:md=\E[1m:mh=\E[2m:mr=\E[7m:\ :me=\E[m:ms:\ :Co#8:pa#64:AF=\E[3%dm:AB=\E[4%dm:op=\E[39;49m:AX:\ :vb=\Eg:G0:as=\E(0:ae=\E(B:\ :ac=\140\140aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++,,hhII00:\ :po=\E[5i:pf=\E[4i:Km=\E[M:k0=\E[10~:k1=\EOP:k2=\EOQ:\ :k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:k7=\E[18~:\ :k8=\E[19~:k9=\E[20~:k;=\E[21~:F1=\E[23~:F2=\E[24~:\ :F3=\E[1;2P:F4=\E[1;2Q:F5=\E[1;2R:F6=\E[1;2S:\ :F7=\E[15;2~:F8=\E[17;2~:F9=\E[18;2~:FA=\E[19;2~:\ :FB=\E[20;2~:FC=\E[21;2~:FD=\E[23;2~:FE=\E[24;2~:kb=^H:\ :K2=\EOE:kB=\E[Z:kF=\E[1;2B:kR=\E[1;2A:*4=\E[3;2~:\ :*7=\E[1;2F:#2=\E[1;2H:#3=\E[2;2~:#4=\E[1;2D:%c=\E[6;2~:\ :%e=\E[5;2~:%i=\E[1;2C:kh=\E[1~:@1=\E[1~:kH=\E[4~:\ :@7=\E[4~:kN=\E[6~:kP=\E[5~:kI=\E[2~:kD=\E[3~:ku=\EOA:\ :kd=\EOB:kr=\EOC:kl=\EOD:km:

Note that if I set TERM=xterm outside of screen I do not get the error message from ncurses. If TERM outside of screen is ncurses the TERM inside of screen is screen and TERMCAP is:
SC|screen|VT 100/ANSI X3.64 virtual terminal:\ :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:bs:bt=\E[Z:\ :cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:ct=\E[3g:\ :do=^J:nd=\E[C:pt:rc=\E8:rs=\Ec:sc=\E7:st=\EH:up=\EM:\ :le=^H:bl=^G:cr=^M:it#8:ho=\E[H:nw=\EE:ta=^I:is=\E)0:\ :li#53:co#234:am:xn:xv:LP:sr=\EM:al=\E[L:AL=\E[%dL:\ :cs=\E[%i%d;%dr:dl=\E[M:DL=\E[%dM:dc=\E[P:DC=\E[%dP:\ :im=\E[4h:ei=\E[4l:mi:IC=\E[%d@:ks=\E[?1h\E=:\ :ke=\E[?1l\E>:vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l:\ :ti=\E[?1049h:te=\E[?1049l:us=\E[4m:ue=\E[24m:so=\E[3m:\ :se=\E[23m:mb=\E[5m:md=\E[1m:mh=\E[2m:mr=\E[7m:\ :me=\E[m:ms:\ :Co#8:pa#64:AF=\E[3%dm:AB=\E[4%dm:op=\E[39;49m:AX:\ :vb=\Eg:G0:as=\E(0:ae=\E(B:\ :ac=\140\140aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++,,hhII00:\ :po=\E[5i:pf=\E[4i:Km=\E[M:k0=\E[10~:k1=\EOP:k2=\EOQ:\ :k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:k7=\E[18~:\ :k8=\E[19~:k9=\E[20~:k;=\E[21~:F1=\E[23~:F2=\E[24~:\ :F3=\E[1;2P:F4=\E[1;2Q:F5=\E[1;2R:F6=\E[1;2S:\ :F7=\E[15;2~:F8=\E[17;2~:F9=\E[18;2~:FA=\E[19;2~:\ :FB=\E[20;2~:FC=\E[21;2~:FD=\E[23;2~:FE=\E[24;2~:kb=^H:\ :K2=\EOE:kB=\E[Z:kF=\E[1;2B:kR=\E[1;2A:*4=\E[3;2~:\ :*7=\E[1;2F:#2=\E[1;2H:#3=\E[2;2~:#4=\E[1;2D:%c=\E[6;2~:\ :%e=\E[5;2~:%i=\E[1;2C:kh=\E[1~:@1=\E[1~:kH=\E[4~:\ :@7=\E[4~:kN=\E[6~:kP=\E[5~:kI=\E[2~:kD=\E[3~:ku=\EOA:\ :kd=\EOB:kr=\EOC:kl=\EOD:km:

Anonymous

 

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

Attach Files:
   
   
Comment:
   

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 sshambar (Posted a comment)
  • -email is unavailable- added by dickey (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    No changes have been made to this item

    Back to the top


    Powered by Savane 3.5