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.)
(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.
(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?)
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.
(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!
This has been released in 2.1.2_pre3-r7.