Skip to content

Terminal emulation: missing primary device attribute response (for fish shell) #4837

@krobelus

Description

@krobelus

Is there an existing issue for this?

  • I have searched the existing issues

Midnight Commander version and build configuration

4.8.33

Operating system

Linux

Is this issue reproducible using the latest version of Midnight Commander?

  • I confirm the issue is still reproducible with the latest version of Midnight Commander

How to reproduce

fish shell >= 4.1 requires the terminal to implement
the Primary Device Attribute.

For now fish has added a workaround; it will not use this query when MC_TMPDIR (or MC_SID, depending on the exact fish version) is set.

To reproduce, disable this workaround; for example by:

diff --git a/lib/vfs/interface.c b/lib/vfs/interface.c
index 831a0ba946..42d045d730 100644
--- a/lib/vfs/interface.c
+++ b/lib/vfs/interface.c
@@ -783,7 +783,7 @@
 
     tmpdir = g_mkdtemp (buffer);
     if (tmpdir != NULL)
-        g_setenv ("MC_TMPDIR", tmpdir, TRUE);
+        ;
     else
     {
         fprintf (stderr,
diff --git a/src/subshell/common.c b/src/subshell/common.c
index bb7bd2701e..4525592d05 100644
--- a/src/subshell/common.c
+++ b/src/subshell/common.c
@@ -337,16 +337,6 @@
     // FIXME? What about when we re-run the subshell?
     MC_UNUSED const int ret_chdir = chdir (mc_config_get_home_dir ());
 
-    // Set MC_SID to prevent running one mc from another
-    mc_sid = getsid (0);
-    if (mc_sid != -1)
-    {
-        char sid_str[BUF_SMALL];
-
-        g_snprintf (sid_str, sizeof (sid_str), "MC_SID=%ld", (long) mc_sid);
-        putenv (g_strdup (sid_str));
-    }
-
     switch (mc_global.shell->type)
     {
     case SHELL_BASH:

Then run mc like

SHELL=$(command -v fish) FISH_DEBUG=reader FISH_DEBUG_OUTPUT=/tmp/fish.log mc

Expected behavior

mc should respond to the Primary DA query, meaning that fish will not hang for two seconds.

As suggested by @egmontkob, mc should maybe be transparent to the shell,
i.e. forward requests and responses to and from the parent terminal. This is how shpool works.

Alternatively, mc could build its own terminal emulation (like tmux) but that probably makes less sense.

Actual behavior

This will hang for two seconds and the resulting /tmp/fish.log will contain a warning:

warning: fish could not read response to Primary Device Attribute query after waiting for 2 seconds.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: ttyInteraction with the terminal, screen librariesprio: mediumHas the potential to affect progress

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions