Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subshell don't save the output of the commands (ctrl+o clear the terminal) #2633

Closed
mc-butler opened this issue Oct 19, 2011 · 23 comments
Closed
Assignees
Labels
area: core Issues not related to a specific subsystem prio: medium Has the potential to affect progress ver: 4.7.5.5 Reproducible in version 4.7.5.5
Milestone

Comments

@mc-butler
Copy link

Important

This issue was migrated from Trac:

Origin https://midnight-commander.org/ticket/2633
Reporter passat (ps@….net)
Mentions woodsb02 (woodsb02@….com)

FreeBSD 8.2-STABLE amd64
# cd /usr/ports/misc/mc
# make && make install && make clean
# rehash
# mc -V
GNU Midnight Commander 4.7.5.5
Built with GLib 2.28.8
Using the S-Lang library with terminfo database
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm
With internationalization support
With multiple codepages support
Virtual File Systems: cpiofs, tarfs, sfs, extfs, ftpfs, fish, smbfs
Data types: char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;

Ctrl+O don't save the output of the commands in the terminal.

But in the GNU Midnight Commander 4.7.5 version it all is ok!

Note

Original attachments:

@mc-butler
Copy link
Author

Changed by angel_il (@ilia-maslakov) on Oct 19, 2011 at 13:31 UTC (comment 1)

please try 4.8.0

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Nov 6, 2011 at 7:26 UTC (comment 2)

  • Milestone set to Future Releases

@mc-butler
Copy link
Author

Changed by fjoe (fjoe@….net) on Dec 5, 2011 at 2:27 UTC (comment 3)

The problem is that "ti" and "te" capabilities are missing in FreeBSD xterm (they are specified only for TERM=xterm-clear).

The "fix" is available here: http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/ports/misc/mc/files/patch-lib-tty-win.c?rev=1.1;content-type=text%2Fplain

@mc-butler
Copy link
Author

Changed by fjoe (fjoe@….net) on Dec 5, 2011 at 2:31 UTC (comment 4)

The same problem exists in 4.8 branch.

@mc-butler
Copy link
Author

Changed by inforus (anton@….me) on Dec 1, 2014 at 23:30 UTC (comment 5)

after update to freebsd 10-stable i have the same problem.
fixed by patch:

--- lib/tty/win.c.orig  2014-09-02 13:23:58.000000000 +0400
+++ lib/tty/win.c       2014-12-02 01:37:37.000000000 +0300
@@ -95,7 +95,7 @@
 void
 do_enter_ca_mode (void)
 {
-    if (mc_global.tty.xterm_flag && smcup != NULL)
+    if (mc_global.tty.xterm_flag)
     {
         fprintf (stdout, /* ESC_STR ")0" */ ESC_STR "7" ESC_STR "[?47h");
         fflush (stdout);
@@ -107,7 +107,7 @@
 void
 do_exit_ca_mode (void)
 {
-    if (mc_global.tty.xterm_flag && rmcup != NULL)
+    if (mc_global.tty.xterm_flag)
     {
         fprintf (stdout, ESC_STR "[?47l" ESC_STR "8" ESC_STR "[m");
         fflush (stdout);



@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Dec 2, 2014 at 5:21 UTC (comment 6)

Ticket #3292 has been marked as a duplicate of this ticket.

@mc-butler
Copy link
Author

Changed by Zmiter (zmiters@….ru) on Mar 17, 2016 at 8:48 UTC (comment 7)

I want to bring this problem up, since it wasn't solved yet.
FreeBSD port misc/mc includes the patch (as showed in comment 6) to solve the blank save console sreen problem, but it's a "crutch". Is there any way to solve this in mc, not the port.
I faced this problem when tried to compile mc by myself, so the patch needs to be applied by hand to everything works as expected.
If it's not forgotten, then sorry for disturb.
Thanks any way for your work. MC is the best tool.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Mar 17, 2016 at 10:16 UTC

Proposed patch

@mc-butler
Copy link
Author

Changed by zaytsev-work (@zyv) on Mar 17, 2016 at 12:45 UTC (comment 8)

@zmiter, as correctly identified by @FJoe:

The problem is that "ti" and "te" capabilities are missing in FreeBSD xterm (they are specified only for TERM=xterm-clear).

So there are 3 possibilities: (1) FreeBSD fixes xterm, (2) FreeBSD carries a patch for mc, or (3) we integrate the patch and make sure it's active only on FreeBSD (Andrew has just proposed such a patch).

I think (3) sucks most, because we have to carry a kludge and if xterm is ever fixed on FreeBSD, most likely nobody will notice that, and this patch will remain in our code forever, degrading the experience on FreeBSD.

Can you talk to the BSD maintainers to see if there is any chance to get (1) done and what their opinion on (2) & (3) is? If they are happy to carry a distro-specific patch, maybe we should just leave it this way and close this as "wontfix".

@mc-butler
Copy link
Author

Changed by Zmiter (zmiters@….ru) on Mar 17, 2016 at 21:13 UTC (comment 9)

After some research I've understood the problem.
My short answer: there is nothing to do, and you can close the ticket.
And here is a more detailed answer.
'ti' and 'te' capabilities for xterm were supportted in FreeBSD some time ago. Then they desided to ammend termcap. But for those who are using these capabilities (smcup, rmcup) they made xterm-clear entry.
So, switching from 'xterm' to 'xterm-clear' make the deal and Ctrl-o saves the screen.
The patch in the port misc/mc actually corrects the problem for those who are aware of switching to 'xterm-clear' (and maybe doesn't know how to do this). It's some kind of a 'crutch'. And it's must not present in mc distro.
In my case (I'm using PuTTY for accessing the FreeBSD) the best solution is to set the name 'xterm-clear' for PuTTY configuration -> Connection -> Data -> Terminal-type string.

Some additional notes. There is one more terminal type called 'putty'. This terminal type support many of PyTTY features and so on. But this terminal type is not recognised by mc as valid xterm or console.

Another note. Terminal type 'xterm-256color' makes it's possible to use 256-color themes from mc in PuTTY console.

The last note. According to win.c in the following function we can see the mode change for saving screen.

void
do_enter_ca_mode (void)
{
    if (mc_global.tty.xterm_flag && smcup != NULL)
    {
        fprintf (stdout, /* ESC_STR ")0" */ ESC_STR "7" ESC_STR "[?47h");
        fflush (stdout);
    }
} 

But the strange thing for me is that the real sequence smcup for the terminal running mc is never sent. Instead of it mc sends the predefined sequence, which in general may not match the termcap 'te' capability.

@mc-butler
Copy link
Author

Changed by Zmiter (zmiters@….ru) on Mar 18, 2016 at 8:04 UTC (comment 10)

One more question. Is there any difference in treating by mc different xterms? So, 'xterm', 'xterm-clear', 'xterm-256color', 'xterm-some-other', will their keybindings be treated different?
My question arose because of keys HOME and END stop working in panels, when I change the terminal type from 'xterm' to 'xterm-clear'. The difference between them ONLY in 'ti' and 'te' caps. All shell working is just fine - no difference. Moreover, learning of keys passes as usual and all keys are recognised.
What might be the problem is?

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Mar 18, 2016 at 8:22 UTC (comment 10.11)

Replying to Zmiter:
Try add in /usr/share/mc/mc.lib:

[terminal:xterm-clear]
copy=xterm

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Mar 18, 2016 at 8:40 UTC (comment 12)

  • Cc set to woodsb02

@woodsb02, since you're our FreeBSD man, could you please chime in and express your opinion on this? Specifically, with regards to comment:8 and comment:9? Many thanks!

@mc-butler
Copy link
Author

Changed by Zmiter (zmiters@….ru) on Mar 18, 2016 at 10:04 UTC (comment 11.13)

Replying to andrew_b:

Replying to Zmiter:
Try add in /usr/share/mc/mc.lib:

[terminal:xterm-clear]
copy=xterm

Thank you very much for your advice, everything works as expected now.
Could it be included in the next release, as 'xterm-clear' is the most 'kosher' terminal to work with mc without any additional patches?

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Oct 24, 2016 at 6:07 UTC (comment 14)

Ticket #3659 has been marked as a duplicate of this ticket.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Oct 24, 2016 at 6:08 UTC (comment 15)

Ticket #3707 has been marked as a duplicate of this ticket.

@mc-butler
Copy link
Author

Changed by quicktrick (quicktrick@….ru) on Sep 28, 2017 at 9:01 UTC (comment 16)

On FreeBSD 11 there is another location of mc.lib: /usr/local/share/mc/mc.lib

After its editing everything works fine! Thanks a lot!

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Oct 21, 2024 at 19:15 UTC (comment 17)

  • Status changed from new to accepted
  • Milestone changed from Future Releases to 4.8.33
  • Owner set to zaytsev

Ship xterm-clear with mclib.

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Oct 22, 2024 at 11:19 UTC (comment 18)

So what a fun story:

  • Pagers like less and editors like vi start supporting screen clearing on exit
  • FreeBSD developer gets annoyed at having his screen wiped and wants to go back to the BSD roots, when these features didn't exist and/or weren't used
    • FreeBSD termcap table is patched to remove ti/te from xterm:
    • New entry xterm-clear is created for people who are against this change
  • Time passes, further developments like xterm-256colors don't take this into account
    • People work around this change around by adding ti/te to their TERMCAP variables
    • misc/mc port is patched, because the "improvement" makes it unusable
    • No attempt is ever made to revert the original "impromevent"
  • At some point another FreeBSD dev tried to get a tab on the termcap & ncurses maintenance problems
  • Current status is that terminfo is used by ncurses if misc/terminfo-db port is installed, termcap is used as fallback - maybe even termcap will be removed one day, who knows
  • The history continues... what's next? Will terminfo eventually be "improved" in the same way as termcap? Or will termcap finally be removed and the original terminfo prevail? We will find out in the next 20 years.

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Oct 22, 2024 at 11:23 UTC (comment 19)

  • Branch state changed from no branch to on review

Branch: 2633_mclib_xterm_clear
Changeset: [f0107ce]

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Oct 22, 2024 at 11:42 UTC (comment 20)

  • Votes set to andrew_b
  • Branch state changed from on review to approved

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Oct 22, 2024 at 12:45 UTC (comment 21)

  • Branch state changed from approved to merged
  • Votes changed from andrew_b to committed-master
  • Status changed from accepted to testing
  • Resolution set to fixed

Merged to master: [4bd73a7]

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Oct 22, 2024 at 12:48 UTC (comment 22)

  • Status changed from testing to closed

@mc-butler mc-butler marked this as a duplicate of #3292 Feb 28, 2025
@mc-butler mc-butler marked this as a duplicate of #3659 Feb 28, 2025
@mc-butler mc-butler marked this as a duplicate of #3707 Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues not related to a specific subsystem prio: medium Has the potential to affect progress ver: 4.7.5.5 Reproducible in version 4.7.5.5
Development

No branches or pull requests

2 participants