Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 152157 - sys-apps/portage-2.1.1-r1 - emerge not restoring xterm title properly
Summary: sys-apps/portage-2.1.1-r1 - emerge not restoring xterm title properly
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 147007
  Show dependency tree
 
Reported: 2006-10-20 12:25 UTC by Jed Liu
Modified: 2006-10-22 14:27 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
don't send a redundant escape sequence (xtermtitle.patch,1.46 KB, patch)
2006-10-21 00:55 UTC, Zac Medico
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jed Liu 2006-10-20 12:25:58 UTC
When emerge exits, it attempts to restore the xterm title to its original state.  It doesn't seem to be doing this properly for me.

In particular, if I run emerge, I get the following:

  $ export PROMPT_COMMAND=
  $ export PS1='\$ '
  $ emerge -pv portage

  These are the packages that would be merged, in order:

  Calculating dependencies... done!
  [ebuild   R   ] sys-apps/portage-2.1.1-r1  USE="-build -doc (-selinux)" LINGUAS="-pl" 294 kB

  Total size of downloads: 294 kB
  sh: -c: line 0: syntax error near unexpected token `;'
  sh: -c: line 0: `{ ; } 2>&1'
  $

If I have PROMPT_COMMAND outputting status, I get:

  $ export PROMPT_COMMAND='echo -ne "\e]2;${PWD}\007"'
  $ emerge -pv portage

  These are the packages that would be merged, in order:

  Calculating dependencies... done!
  [ebuild   R   ] sys-apps/portage-2.1.1-r1  USE="-build -doc (-selinux)" LINGUAS="-pl" 294 kB

  Total size of downloads: 294 kB
  $ 0;$

The cursor ends up on top of the '0', and the terminal beeps.

If I do this in GNU screen, I get:

  $ export PROMPT_COMMAND='echo -ne export PROMPT_COMMAND='echo -ne "\033_$PWD\033\\"'
  $ cd /tmp
  $ emerge -pv portage

  These are the packages that would be merged, in order:

  Calculating dependencies... done!
  [ebuild   R   ] sys-apps/portage-2.1.1-r1  USE="-build -doc (-selinux)" LINGUAS="-pl" 294 kB

  Total size of downloads: 294 kB
  $ 1;_/tmp]2;[screen 10] _/tmp$

Again, the cursor ends up on top of the '1' and the terminal beeps.  Even more annoying, if I switch to another screen and switch back, I get "]1;_/tmp" at the upper left of the screen, followed by a terminal beep, followed by the actual contents of the screen.  (It stays "/tmp" even when I change to a different directory.)
Comment 1 Zac Medico gentoo-dev 2006-10-20 15:43:15 UTC
(In reply to comment #0)
> When emerge exits, it attempts to restore the xterm title to its original
> state.  It doesn't seem to be doing this properly for me.
> 
> In particular, if I run emerge, I get the following:
> 
>   $ export PROMPT_COMMAND=

I've fixed the case for empty PROMPT_COMMAND in svn r4771.

> If I have PROMPT_COMMAND outputting status, I get:
> 
>   $ export PROMPT_COMMAND='echo -ne "\e]2;${PWD}\007"'
>   $ emerge -pv portage
> 
>   These are the packages that would be merged, in order:
> 
>   Calculating dependencies... done!
>   [ebuild   R   ] sys-apps/portage-2.1.1-r1  USE="-build -doc (-selinux)"
> LINGUAS="-pl" 294 kB
> 
>   Total size of downloads: 294 kB
>   $ 0;$
> 
> The cursor ends up on top of the '0', and the terminal beeps.

I'm able to reproduce that but I'm not sure what's going wrong yet.  Portage simply uses commands.getoutput() to execute PROMPT_COMMAND, and then outputs "\x1b]0;" + prompt_command_output + "\x07" to stderr.
Comment 2 Jed Liu 2006-10-20 23:16:38 UTC
(In reply to comment #1)
> I'm able to reproduce that but I'm not sure what's going wrong yet.  Portage
> simply uses commands.getoutput() to execute PROMPT_COMMAND, and then outputs
> "\x1b]0;" + prompt_command_output + "\x07" to stderr.
> 
Maybe I don't completely understand xterm escape sequences, but shouldn't the correct behaviour be to omit those extra escape sequences and just output "prompt_command_output" to stderr?  (I assume PROMPT_COMMAND is being emulated so that the xterm title is restored even when emerge is called from a script?)
Comment 3 Zac Medico gentoo-dev 2006-10-21 00:55:37 UTC
Created attachment 100118 [details, diff]
don't send a redundant escape sequence

(In reply to comment #2)
> Maybe I don't completely understand xterm escape sequences, but shouldn't the
> correct behaviour be to omit those extra escape sequences and just output
> "prompt_command_output" to stderr?

Yes, that makes sense. It's fixed in svn r4782.
Comment 4 Jed Liu 2006-10-21 01:37:15 UTC
(In reply to comment #3)
> > Maybe I don't completely understand xterm escape sequences, but shouldn't the
> > correct behaviour be to omit those extra escape sequences and just output
> > "prompt_command_output" to stderr?
> 
> Yes, that makes sense. It's fixed in svn r4782.
> 
Hmm, now that I think about it, it's a little more complicated than that.  PROMPT_COMMAND could output more than just stuff that sets the xterm title.  (For example, PROMPT_COMMAND='echo foo'.)

What really should be done is to parse "prompt_command_output" to remove anything that doesn't set the xterm title.  I can see this as being annoying to do -- for example, I use different escape codes depending on whether I'm in GNU screen (cf. comment #0).  The above patch suits my needs for now, though.

Thanks!
Comment 5 Zac Medico gentoo-dev 2006-10-22 14:27:24 UTC
This has been released in 2.1.2_pre3-r7.