RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 620408 - Text might be put in the terminal title instead of the terminal itself
Summary: Text might be put in the terminal title instead of the terminal itself
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: setup
Version: 6.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Ondrej Vasik
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
: 705669 (view as bug list)
Depends On:
Blocks: 620443
TreeView+ depends on / blocked
 
Reported: 2010-08-02 13:22 UTC by Tomas Smetana
Modified: 2018-11-14 19:27 UTC (History)
5 users (show)

Fixed In Version: setup-2.8.14-11.el6
Doc Type: Bug Fix
Doc Text:
Bash provides the environment variable, PROMPT_COMMAND, containing a command that is called when a prompt is displayed. Previously, the PROMPT_COMMAND command used two separate echo commands. Consequently, if a background process returned text, the text might have displayed in the X terminal title rather than the terminal itself. In this updated package, the PROMPT_COMMAND command uses a single printf statement rather than two echo commands, ensuring returned text displays in the shell.
Clone Of:
: 620435 620443 (view as bug list)
Environment:
Last Closed: 2011-05-19 11:54:34 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:0524 0 normal SHIPPED_LIVE setup bug fix and enhancement update 2011-05-18 17:44:56 UTC

Description Tomas Smetana 2010-08-02 13:22:22 UTC
Description of problem:
Due to the fix of bug #142125 the default PROMPT_COMMAND has been set to a list of two commands.  This causes strange behaviour when the output of a background process might get flushed after the output of the first PROMPT_COMMAND echo and hence appear between the escape sequences which mark the X terminal title.  It also means the text doesn't appear in the terminal itself.

Version-Release number of selected component (if applicable):
bash-4.1.2-2.el6.x86_64

How reproducible:
Sometimes

Steps to Reproduce:
1. In xterm/gnome-terminal/Terminal run: yes &
2. while 'yes' is running: cat /var/log/yum.log (or whatever application which prints out something on the terminal and takes some time)
3. Look at the terminal title -- it would read something like "tsmetana@localhost:~/bash_testy y y y y y"
4. if not GOTO 2.
  
Actual results:
The text printed in the terminal title was not printed in the terminal window (this can be verified by running something else than 'yes' -- e.g. a simple c-program which outputs a number sequence)

Expected results:
The output of PROMPT_COMMAND shouldn't get mixed with the other text that goes to the terminal.

Additional info:
There is a simple way to check the more commands in PROMPT_COMMAND can have unusual consequence -- try to add sleep between the two commands:

export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; sleep 1; echo -ne "\007"'

Now just press enter and some random keys on the keyboard, then look at the xterm title -- it would contain the keys you pressed.  Note that the sleep only increases the chance for this to happen.

I'm not actually sure how to solve the problem properly: maybe the bug #142125 has to be fixed some other way and PROMPT_COMMAND should be reverted to the old value with just one echo command.

Comment 1 Roman Rakus 2010-08-02 13:42:28 UTC
I guess we should use `printf' instead of `echo'.

Comment 2 Roman Rakus 2010-08-02 14:08:23 UTC
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#HOME/~}"'

works for me. Reassigning to setup.

Comment 3 Tomas Smetana 2010-08-18 08:23:24 UTC
Hello,
  just a small correction: It looks like there is a $ sign missing before HOME. The correct value should look like this:

PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'

Comment 7 Florian Nadge 2011-03-02 18:18:14 UTC
Please be so kind and add a few key words to the technical note of this
bugzilla entry using the following structure:

Cause:

Consequence:

Fix:

Result:


For details, see:
https://bugzilla.redhat.com/page.cgi?id=fields.html#cf_release_notes

Thanks

Comment 8 Florian Nadge 2011-03-02 18:18:15 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause
    What actions or circumstances induced the feature request.
Consequence
    What action was inhibited by the feature’s absence.
Change
    What was done to implement the feature.
    Note: backported from upstream is not an explanation.
Result
    What now happens when the actions or circumstances above occur.
    Note: this is not the same as the feature request was fulfilled.

Comment 9 Ondrej Vasik 2011-03-03 09:05:52 UTC
These are already present in errata description text ... but ok, adding to technotes field.

Comment 10 Ondrej Vasik 2011-03-03 09:05:52 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,10 +1 @@
-Cause
+Under some circumstances (running background process displaying some text), PROMPT_COMMAND environmental variable could cause that the text is shown in the X terminal title, instead of the terminal itself. This was caused by bad design of the PROMPT_COMMAND. Design was improved and single printf was used instead of two separate echo commands, thus preventing the issue.-    What actions or circumstances induced the feature request.
-Consequence
-    What action was inhibited by the feature’s absence.
-Change
-    What was done to implement the feature.
-    Note: backported from upstream is not an explanation.
-Result
-    What now happens when the actions or circumstances above occur.
-    Note: this is not the same as the feature request was fulfilled.

Comment 12 Ryan Lerch 2011-04-19 23:24:12 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-Under some circumstances (running background process displaying some text), PROMPT_COMMAND environmental variable could cause that the text is shown in the X terminal title, instead of the terminal itself. This was caused by bad design of the PROMPT_COMMAND. Design was improved and single printf was used instead of two separate echo commands, thus preventing the issue.+Bash provides the environment variable, PROMPT_COMMAND, containing a command that is called when a prompt is displayed. Previously, the PROMPT_COMMAND command used two separate echo commands. Consequently, if a background process returned text, the text might have displayed in the X terminal title rather than the terminal itself. In this updated package, the PROMPT_COMMAND command uses a single printf statement rather than two echo commands, ensuring returned text displays in the shell.

Comment 15 Roman Rakus 2011-05-18 13:51:36 UTC
*** Bug 705669 has been marked as a duplicate of this bug. ***

Comment 16 errata-xmlrpc 2011-05-19 11:54:34 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0524.html


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