Bug 2248853
| Summary: | Colored prompt is not set for login shells | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Sam Morris <sam> | ||||
| Component: | shell-color-prompt | Assignee: | Jens Petersen <petersen> | ||||
| Status: | CLOSED ERRATA | QA Contact: | |||||
| Severity: | medium | Docs Contact: | |||||
| Priority: | unspecified | ||||||
| Version: | 39 | CC: | petersen | ||||
| Target Milestone: | --- | ||||||
| Target Release: | --- | ||||||
| Hardware: | All | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | shell-color-prompt-0.2-1.fc39 shell-color-prompt-0.2-1.fc37 shell-color-prompt-0.2-1.fc38 shell-color-prompt-0.2-1.el9 | Doc Type: | If docs needed, set a value | ||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2023-11-14 01:44:11 UTC | Type: | --- | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Attachments: |
|
||||||
Created attachment 1998060 [details]
0001-Set-prompt-when-called-from-a-login-shell.patch
Having some trouble getting an SSH key set up on Fedora Pagure so here's an old fashioned patch.
Thanks for this. I will include it in coming 0.2. FEDORA-2023-3e862eb724 has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-3e862eb724 This should be fixed in 0.2, which I built for F39 and F40 so far. Thanks! FEDORA-2023-fb9fbe1bed has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-fb9fbe1bed FEDORA-2023-3e862eb724 has been pushed to the Fedora 39 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-3e862eb724` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-3e862eb724 See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates. FEDORA-2023-79d91fcab0 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-79d91fcab0 FEDORA-EPEL-2023-dc012e88bc has been submitted as an update to Fedora EPEL 9. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2023-dc012e88bc FEDORA-2023-fb9fbe1bed has been pushed to the Fedora 38 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-fb9fbe1bed` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-fb9fbe1bed See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates. FEDORA-EPEL-2023-dc012e88bc has been pushed to the Fedora EPEL 9 testing repository. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2023-dc012e88bc See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates. FEDORA-2023-79d91fcab0 has been pushed to the Fedora 37 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-79d91fcab0` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-79d91fcab0 See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates. FEDORA-2023-3e862eb724 has been pushed to the Fedora 39 stable repository. If problem still persists, please make note of it in this bug report. FEDORA-2023-79d91fcab0 has been pushed to the Fedora 37 stable repository. If problem still persists, please make note of it in this bug report. FEDORA-2023-fb9fbe1bed has been pushed to the Fedora 38 stable repository. If problem still persists, please make note of it in this bug report. FEDORA-EPEL-2023-dc012e88bc has been pushed to the Fedora EPEL 9 stable repository. If problem still persists, please make note of it in this bug report. |
When I SSH into a system where bash-color-prompt is installed I get the traditional monochrome prompt. If I run 'bash -l' at this point, the shell is launched with a monochrome prompt. Setting prompt_color_force in either .bash_profile or .bashrc has no affect. Whereas running 'bash' launches a shell with a color prompt. Reproducible: Always Steps to Reproduce: 1. Install bash-color-prompt 2. SSH into machine Actual Results: Prompt is not colored Expected Results: Prompt should be colored Adding some 'echo' commands to the top of the various initialization files reveales the order they are called: [sam@host ~]$ bash -l /etc/profile bash-color-prompt.sh /etc/bashrc .bash_profile .bashrc /etc/bashrc So because this is a login shell, /etc/profile is sourced first. This goes on to source /etc/profile.d/bash-color-prompt.sh which checks that PS1 is set to its traditional Fedora default before enabling the color prompt. But at this point, /etc/bashrc has not run yet, which is the compoment that changes PS1 to its traditional Fedora default; at the time /etc/profile runs, PS1 is still set to the bash default. Here's the test in bash-color-prompt.sh: if [ "$PS1" = "[\u@\h \W]\\$ " -a "${TERM: -5}" = "color" -o -n "${prompt_color_force}" ]; then And here's how /etc/bashrc sets PS1: [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ " The hacky way to fix this is to rewrite bash-color-prompt.sh's test as: if [ '(' "$PS1" = "[\u@\h \W]\\$ " -o "$PS1" = "\\s-\\v\\\$ " ')' -a "${TERM: -5}" = "color" -o -n "${prompt_color_force}" ]; then i.e., checking that PS1 is either set to bash's default or Fedora's traditional default. It would be better to set the color prompt directly in /etc/bashrc so that it's done consistently during the shell initialization process regardless of whether the shell is a login shell or not but that's a wider-scoped change.