Ticket #4258 (accepted defect)
Wrong subshell prompt parsing with fish 3.3.0
Reported by: | olfway | Owned by: | andrew_b |
---|---|---|---|
Priority: | major | Milestone: | Future Releases |
Component: | mc-core | Version: | master |
Keywords: | Cc: | johannes | |
Blocked By: | Blocking: | ||
Branch state: | on rework | Votes for changeset: |
Description
Fish 3.3.0 sends \r while printing prompt and mc erases prompt buffer
This change was introduced by https://github.com/fish-shell/fish-shell/pull/8011
It starts working after I modify parse_subshell_prompt_string function:
/* Extract the prompt from the shell output */ for (i = 0; i < bytes; i++) - if (buffer[i] == '\n' || buffer[i] == '\r') + if (buffer[i] == '\n') g_string_set_size (subshell_prompt_temp_buffer, 0); else if (buffer[i] != '\0') g_string_append_c (subshell_prompt_temp_buffer, buffer[i]);
Attachments
Change History
comment:1 Changed 3 years ago by andrew_b
- Status changed from new to accepted
- Owner set to andrew_b
- Branch state changed from no branch to on review
Branch: 4258_fish_shell_prompt
changeset:e819ed742118dd4b9fc7d37e82830118df366ca4
Please test.
comment:2 Changed 3 years ago by olfway
I tried to run it and unfortunately it doesn't work - same empty prompt
So dumped buffer to a temporary file:
/W/l/m/mc^[(B^[[m (4258_fish_shell_prompt)^[(B^[[m> ^[[K^M^[[53C
and tried to "translate" this:
/W/l/m/mc - Text ^[(B - Start sequence defining G0 character set, Select default (ISO 8859-1 mapping) ^[[m - Select Graphic Rendition, reset all attributes to their defaults (4258_fish_shell_prompt) - Text ^[(B - Start sequence defining G0 character set, Select default (ISO 8859-1 mapping) ^[[m - Select Graphic Rendition, reset all attributes to their defaults > - Text ^[[K - Erase line (default: from cursor to end of line). ^M - Carriage Return, moves the cursor to column zero ^[[53C - Move cursor right the indicated # of columns (53 here)
EDIT: Just realized this buffer also seems truncated,
but maybe something was wrong with my dump code
comment:3 Changed 3 years ago by olfway
This for example multiline prompt (same empty prompt in mc):
2m~/W/l/m/mc^[(B^[[m|^[[31m4258_fish_shell_prompt⚡^[[34m*^[[33m?^[(B^[[m^M ➤ ^[(B^[[m^[[K^M^[[C^[[C
Actually it looks truncated, it probably should be like
user123@host123:~/W/l/m/mc|4258_fish_shell_prompt⚡*? ➤
comment:5 Changed 3 years ago by olfway
9 months passed and it still broken :(
Any chances it could be fixed?
I had custom mc build with my change (as in description) and it works perfectly
comment:7 Changed 2 weeks ago by zaytsev
- Cc johannes added
Related discussion in fish: https://github.com/fish-shell/fish-shell/issues/8091 .
Johannes, since you seem to be active in fish, can you say something about this? Andrew started working on this, but never got to finish it. I wonder if this is still relevant to fish users.
comment:8 Changed 2 weeks ago by johannes
I haven't been able to reproduce this yet (but I remember seeing this missing prompt sometimes).
I put this in my config.fish
`
function fish_right_prompt
printf asdf
end
`
and ran mc
I confirmed that fish prints "M[[90Casdf"
so \r then moves the cursor 90 characters right and then prints the right prompt.
comment:9 Changed 2 weeks ago by johannes
oh it's because mc explicitly erases the right prompt since c5aaeda39 (Ticket 3944: support user-defined prompt in the fish subshell., 2018-10-21)
If I remove the "functions -e fish_right_prompt", then the issue reproduces.
fish normally also uses \r before the normal prompt but they added a hack to not do that if running inside midnight commander,
(https://github.com/fish-shell/fish-shell/commit/b1b2294390b2a84afdf229d33b3a8bce51ea1a4f (Add workaround for Midnight Commander's issue with prompt extraction, 2023-02-04).
So this ticket seems worked around in the upcoming fish 4.0 release.
Should probably still fix it in mc.. but this is all a bit hacky, I guess the way forward is for mc to behave more like a terminal but it's already running inside another one. I wonder if there is a better architecture for this UI.