Created attachment 923698 [details]
Fix PROMPT_COMMAND default definition
Description of problem:
When running 'mock --shell', PROMPT_COMMAND is incorrect (does not set window title). This is due to the lack of \033]0; and \007.
Version-Release number of selected component (if applicable):
1.1.39 and git master
Steps to Reproduce:
1. Run mock --shell
"<mock-chroot>" is prepended to the command prompt. This also causes spacing error's if you press up/down to go through command history.
Window title should be "<mock-chroot>", command prompt should not be prepended.
My patch switches PROMPT_COMMAND from 'echo -n' to 'printf'. The '-e' parameter could be used with echo, but I decided to use a command closer to what is used in the CentOS PROMPT_COMMAND.
Created attachment 923719 [details]
Fix PROMPT_COMMAND default definition (attempt 2)
First patch was missing a definition
Going with printf in the PROMPT_CMD is probably a good idea.
Setting the terminal window makes sense for xterm type situations.
But what about when mock is operated from a root console?
(think headless server, with serial console)
Hopefully the escape sequences have no impact in windowless terminals.
(E.G. produce garbled text on the prompt)
Can someone please test the proposed patch in a dumb-terminal type setup to ensure this does not introduce a bug?
Hey also, this is not a bug fix.
More like an enhancement request.
Actually the existing PROMPT_COMMAND does cause issues currently with certain commands in history. Maybe it's a bug in bash. For example given the following history:
ls -lh build
if you arrow up through history, setting the variable causes the prompt to be displayed incorrectly. Going back through the above history:
<mock-chroot>[root@mock1 ~]# echo "nothing"
<mock-chroot>[root@mock1 ~]# SOMEVAR="some value"
In this example it seems to be the line that sets a bash variable which causes the next arrow-up through history to truncate the prompt, seems to be based on the length of $PS1 output, instead of being the length of output from "`$PROMPT_COMMAND`$PS1".
So I still believe this is a bug, the prompt display should not be broken like this. If my patch poses a problem for dumb terminals then we may need to clear PROMPT_COMMAND and consider prepending $PS1 instead.
As for the (possible) bug in bash, I am running bash-4.1.2-15.el6_4.x86_64 (CentOS 6). What is the best way to ensure this bug is seen by those who work on bash?
It does not work for me - I am using konsole from KDE (however I can confirm corruption of prompt as reproduced in #4).
I search how title bar should be set and it seems that it is non-trivial:
Your code seems to work in xterm - although to preserve <moch-chroot> text even on PS1 it should be:
environ['PROMPT_COMMAND'] = 'printf "\033]0;<mock-chroot>\007<mock-chroot>"'
with this modification there is no regression in headless mode (did not print garbage), in konsole (did not set title, but neither previously) and works now in xterm.
Therefore I see it as safe to accept.
With small modification committed as 03aa277
mock-1.2.1-1.fc21 has been submitted as an update for Fedora 21.
mock-1.2.1-1.fc20 has been submitted as an update for Fedora 20.
mock-1.2.1-1.el7 has been submitted as an update for Fedora EPEL 7.
mock-1.2.1-1.el6 has been submitted as an update for Fedora EPEL 6.
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing mock-1.2.1-1.fc20'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).
mock-1.2.3-1.fc21 has been submitted as an update for Fedora 21.
mock-1.2.3-1.fc20 has been submitted as an update for Fedora 20.
mock-1.2.3-1.el7 has been submitted as an update for Fedora EPEL 7.
mock-1.2.3-1.fc21 has been pushed to the Fedora 21 stable repository. If problems still persist, please make note of it in this bug report.
mock-1.2.3-1.fc20 has been pushed to the Fedora 20 stable repository. If problems still persist, please make note of it in this bug report.
mock-1.2.3-1.el7 has been pushed to the Fedora EPEL 7 stable repository. If problems still persist, please make note of it in this bug report.