mc midnightcommander wrong $PS1 parser in command line input

Bug #330633 reported by Michele Mordenti on 2009-02-17
This bug affects 6 people
Affects Status Importance Assigned to Milestone
Midnight Commander
Fix Released
mc (Ubuntu)
Nominated for Jaunty by olksy

Bug Description

Binary package hint: mc

Current path are wrong in command line input, if I go for example in /var/cache/apt/archives it displays:
"0;mordentim@monstermord: /var/cache/apt/archivesmordentim@monstermord:/var/cache/apt/archives$ "
instead of "mordentim@monstermord:/var/cache/apt/archives$"

System informations:

echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$

mordentim@monstermord:~$ uname -a
Linux monstermord 2.6.28-7-server #20-Ubuntu SMP Mon Feb 9 16:33:23 UTC 2009 i686 GNU/Linux

mordentim@monstermord:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu jaunty (development branch)
Release: 9.04
Codename: jaunty

mc version:
ii mc 2:4.6.2~git20080311-4 midnight commander - a powerful file manager

Nuno Silva (nuno-nunosilva) wrote :

I confirm. Today (2009-04-02) it's still showing the garbled prompt in up-to-date Jaunty.
Changing PS1 to '\u@\h:\w\$ ' fixes the "bad" prompt in mc's sub-shell.

Changed in mc (Ubuntu):
status: New → Confirmed
Nuno Silva (nuno-nunosilva) wrote :

Just to give some more details:
The "complex" PS1 is set in ~/.bashrc, and comes from /etc/skel.

This happens when TERM=xterm, here:
case "$TERM" in
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

Midnight Commander doesn't like it, and the sub-shell prompt looks like this, while in the home dir:
Hint: You may specify the external viewer with the shell vars VIEWER or PAGER.
0;nuno@kubuntu: ~nuno@kubuntu:~$
1Help 2Menu 3View 4Edit 5Copy 6RenMov 7Mkdir 8Delete 9PullDn 10Quit

This happens in konsole and xterm. The easy workaround is to comment out the PS1 line mentioned above. The Right Way (C) would be to fix mc.

This is only "cosmetic", but I'm addicted to mc since 199x, so... :-)


On 2009-04-02 at 13:00 -0000, Nuno Silva wrote:

> This happens in konsole and xterm. The easy workaround is to comment out
> the PS1 line mentioned above. The Right Way (C) would be to fix mc.

A better workaround ist to set PS1 specifically for mc's subshell:
$ echo PS1=\'\\u@\\h:\\w\\$ \' >> ~/.mc/bashrc

Alexey Osipov (lion-simba) wrote :

Confirm this. Jaunty release. Very annoying.

Sergey Nizovtsev (snizovtsev) wrote :

New PS1 in Ubuntu uses the OSC (Operating System Command) escape sequence to set title in a terminal emulator, but mc can't skip this.
I have written the patch that skips this sequences. It should be applied after all ubuntu patches. Modified function 'strip_ctrl_codes' is used only for command prompt and can't break anything else.

Sergey Nizovtsev (snizovtsev) wrote :

I've built amended mc package for Jaunty - you can download the packages from my PPA at:

Maia Everett (linneris) wrote :

Is this relevant to Debian, or just Ubuntu?

It would be nice if you uploaded a full debdiff against the current archive version with a debian/changelog entry, but this is optional.

Changed in mc (Ubuntu):
assignee: nobody → Maia Kozheva (sikon)
Maia Everett (linneris) wrote :

Added upstream bug report link (thanks to slavazanko). The patch above does not take all cases into consideration, but upstream will use it as a basis for their fix.

Unsubscribing u-u-s for now.

Changed in mc (Ubuntu):
assignee: Maia Kozheva (sikon) → nobody
importance: Undecided → Low
status: Confirmed → Triaged
Changed in mc:
status: Unknown → Confirmed
Changed in mc:
status: Confirmed → Fix Released
Sebastien Bacher (seb128) wrote :

Should the sponsor team be unsubscribed as written before? could you send the change to debian?

Michele Mordenti (micmord) wrote :

Fixed on Lucid.

Changed in mc (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.