Bug 1126235 - PROMPT_COMMAND does not include required escape codes
Summary: PROMPT_COMMAND does not include required escape codes
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: mock
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: Miroslav Suchý
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-03 21:57 UTC by Corey Farrell
Modified: 2015-01-06 02:06 UTC (History)
6 users (show)

Fixed In Version: mock-1.2.3-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-12-12 04:08:04 UTC


Attachments (Terms of Use)
Fix PROMPT_COMMAND default definition (1.25 KB, patch)
2014-08-03 21:57 UTC, Corey Farrell
no flags Details | Diff
Fix PROMPT_COMMAND default definition (attempt 2) (1.62 KB, patch)
2014-08-04 01:31 UTC, Corey Farrell
no flags Details | Diff

Description Corey Farrell 2014-08-03 21:57:15 UTC
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

How reproducible:
Every time

Steps to Reproduce:
1. Run mock --shell

Actual results:
"<mock-chroot>" is prepended to the command prompt.  This also causes spacing error's if you press up/down to go through command history.

Expected results:
Window title should be "<mock-chroot>", command prompt should not be prepended.

Additional info:
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.

Comment 1 Corey Farrell 2014-08-04 01:31:29 UTC
Created attachment 923719 [details]
Fix PROMPT_COMMAND default definition (attempt 2)

First patch was missing a definition

Comment 2 Jon Disnard 2014-08-07 19:52:57 UTC
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?

Comment 3 Jon Disnard 2014-08-07 20:43:00 UTC
Hey also, this is not a bug fix.

More like an enhancement request.

Comment 4 Corey Farrell 2014-08-08 23:48:50 UTC
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
echo "hello"
SOMEVAR="some value"
echo "nothing"

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"
<mock-chroot>[roecho "hello"

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?

Comment 5 Miroslav Suchý 2014-10-20 14:29:27 UTC
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:
  http://www.fvue.nl/wiki/Bash:_How_to_change_tab_and_window_title_of_console

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

Comment 6 Fedora Update System 2014-11-16 17:37:29 UTC
mock-1.2.1-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/mock-1.2.1-1.fc21

Comment 7 Fedora Update System 2014-11-16 17:38:51 UTC
mock-1.2.1-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.2.1-1.fc20

Comment 8 Fedora Update System 2014-11-16 17:39:42 UTC
mock-1.2.1-1.el7 has been submitted as an update for Fedora EPEL 7.
https://admin.fedoraproject.org/updates/mock-1.2.1-1.el7

Comment 9 Fedora Update System 2014-11-16 17:40:43 UTC
mock-1.2.1-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.2.1-1.el6

Comment 10 Fedora Update System 2014-11-17 06:29:49 UTC
Package mock-1.2.1-1.fc20:
* 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:
https://admin.fedoraproject.org/updates/FEDORA-2014-15217/mock-1.2.1-1.fc20
then log in and leave karma (feedback).

Comment 11 Fedora Update System 2014-12-04 12:07:07 UTC
mock-1.2.3-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/mock-1.2.3-1.fc21

Comment 12 Fedora Update System 2014-12-04 12:10:36 UTC
mock-1.2.3-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.2.3-1.fc20

Comment 13 Fedora Update System 2014-12-04 12:11:33 UTC
mock-1.2.3-1.el7 has been submitted as an update for Fedora EPEL 7.
https://admin.fedoraproject.org/updates/mock-1.2.3-1.el7

Comment 14 Fedora Update System 2014-12-12 04:08:04 UTC
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.

Comment 15 Fedora Update System 2014-12-17 04:43:06 UTC
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.

Comment 16 Fedora Update System 2015-01-06 02:06:51 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.