Bug 1183192

Summary: vte-profile's vte.sh overrides any earlier setting of PROMPT_COMMAND (and duplicates /etc/bashrc)
Product: [Fedora] Fedora Reporter: DO NOT USE account not monitored (old adamwill) <adamw+fedora>
Component: vte291Assignee: Debarshi Ray <debarshir>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 35CC: alick9188, awilliam, ced, chpe, debarshir, dgunchev, egmont, garrett.mitchener, jtudelag, kalevlember, klember, lzachar, samuel.rakitnican, uvsmtid
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-06-15 19:57:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
proposed fix none

Description DO NOT USE account not monitored (old adamwill) 2015-01-17 00:30:58 UTC
/etc/bashrc has this:

    case $TERM in
    xterm*|vte*)
      if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
          PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
      elif [ "${VTE_VERSION:-0}" -ge 3405 ]; then
          PROMPT_COMMAND="__vte_prompt_command"
      else
          PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'

then /etc/profile.d/vte.sh has:

case "$TERM" in
  xterm*|vte*)
    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command" 
    [ -n "$ZSH_VERSION"  ] && precmd_functions+=(__vte_osc7)
    ;;
esac

first of all, why is this duplicated between the two? Seems unnecessary.

Second, vte.sh doesn't incorporate any previous PROMPT_COMMAND. That means if you create a /etc/profile.d/prompt.sh (for e.g.) and set a custom PROMPT_COMMAND in it, it doesn't work, because vte.sh is included later and overrides it. You have to name your file so it comes alphabetically after vte.sh if you want to set a custom PROMPT_COMMAND.

Comment 1 Egmont Koblinger 2015-01-17 10:09:59 UTC
Re "Second": See https://bugzilla.gnome.org/show_bug.cgi?id=704960 , I'll fix it for the next release.

Comment 2 Christian Persch 2015-01-17 10:44:40 UTC
The (bogus) /etc/bashrc change comes from bug 924275.

And it's done in vte.sh because vte.sh is upstream, while /etc/bashrc is fedora specific.

In bug 924275 comment 13 I had proposed a way to make this work nicely, but it wasn't well-received.

Comment 3 Jaroslav Reznik 2015-03-03 16:43:29 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora22

Comment 4 srakitnican 2016-03-02 18:11:03 UTC
Still present in Fedora 23.

$ rpm -q vte291 vte-profile
vte291-0.42.3-1.fc23.x86_64
vte-profile-0.42.3-1.fc23.x86_64

Comment 5 Adam Williamson 2016-03-02 18:27:53 UTC
Christian: the failure to incorporate previously set PROMPT_COMMAND seems like a problem specific to vte that can be fixed without anyone else's say-so...

Comment 6 Garrett Mitchener 2016-07-18 22:30:57 UTC
Still in Fedora 24. This gets in the way of autojump.

Comment 7 Fedora End Of Life 2016-07-19 12:39:15 UTC
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 8 srakitnican 2016-07-19 15:52:04 UTC
Created attachment 1181684 [details]
proposed fix

VTE is overwriting system ENV variable, this is then a vte bug as I see it. IMHO it should be either fixed or removed because it _breaks_ ENV variable.

It should be fixed at least temporarily by appending its stuff to the PROMPT_COMMAND and not overwriting, and again IMHO.

I don't think it should be removed since the fix is so simple as I see it. As said by autojump developer:

> For bash users, autojump keeps track of directories by modifying $PROMPT_COMMAND. Do not overwrite $PROMPT_COMMAND:
> 
>   export PROMPT_COMMAND="history -a"
> 
> Instead append to the end of the existing \$PROMPT_COMMAND:
> 
>   export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ;} history -a"


And this seems as right fix to me.

Comment 9 Fedora End Of Life 2017-02-28 09:39:56 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 26 development cycle.
Changing version to '26'.

Comment 10 Debarshi Ray 2017-03-23 13:44:56 UTC
So, why can't we have this:
https://bugzilla.redhat.com/show_bug.cgi?id=924275#c13 ?

Other than handwaving it away as "playing with arrays for PROMPT_COMMAND seems to be over-engineering".

Comment 11 Debarshi Ray 2017-03-23 13:48:50 UTC
To be honest, if Bash or the Fedora start-up script maintainers really don't want the terminal emulator to override global environment variables, then they should try harder to offer suitable facilities. If its considered "over-engineering", then why should vte bother?

Comment 12 srakitnican 2017-07-19 09:19:19 UTC
(In reply to Debarshi Ray from comment #11)
> To be honest, if Bash or the Fedora start-up script maintainers really don't
> want the terminal emulator to override global environment variables, then
> they should try harder to offer suitable facilities. If its considered
> "over-engineering", then why should vte bother?

Hi, I am not sure what you mean, but the way I see it, bashrc is not overwriting PROMPT_COMMAND variable:

# are we an interactive shell?
if [ "$PS1" ]; then
  if [ -z "$PROMPT_COMMAND" ]; then
    case $TERM in


But vte.sh is:

case "$TERM" in
  xterm*|vte*)
    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command"

I think vte should stop doing this.

Comment 13 Jan Kurik 2017-08-15 09:28:28 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.

Comment 14 Alexey Pakseykin 2018-03-17 17:35:06 UTC
PROMPT_COMMAND override, IMO, is clearly intrusive.
It's even more annoying when all it seems to solve are:
  1. "Command completed" notification for Gnome shell.
  2. New tab is opened in the same directory as the existing tab.
  ...
     Is there something else?

For example, for `tmux` users, both points become irrelevant.

I tried to `dnf erase vte-profile` but it got itself as dependency
for many important packages (directly or indirectly).

More over, `/etc/profile.d/vte.sh` is the only file `vte-profile` package provides.


Solution:

  Shouldn't solution for Fedora be in simple RPM-dependency fix?
  What if it can become completely optional?

  For example:
  It could be included by default with GNOME
  (with all other stuff like `gedit).
  But if you uninstall it, it erases itself only.

  
Otherwise (fixing it on `vte.sh` side) is blocked by resistance:
https://bugzilla.gnome.org/show_bug.cgi?id=704960

Comment 15 Ben Cotton 2018-11-27 16:36:16 UTC
This message is a reminder that Fedora 27 is nearing its end of life.
On 2018-Nov-30  Fedora will stop maintaining and issuing updates for
Fedora 27. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora  'version' of '27'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 27 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 16 Adam Williamson 2018-11-27 19:37:14 UTC
I don't see any change in vte.sh in current Rawhide. The upstream bug seemed to get into an argument and then be abandoned...

Comment 17 Alick Zhao 2018-12-09 19:58:11 UTC
IMO Fedora should patch vte.sh for now since upstream does not think there is urgent need of fixing this. But is the package owner still actively maintaining the package?

Comment 18 Ben Cotton 2019-02-19 17:11:33 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 30 development cycle.
Changing version to '30.

Comment 19 Ben Cotton 2020-04-30 22:17:50 UTC
This message is a reminder that Fedora 30 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 30 on 2020-05-26.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '30'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 30 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 20 Lukáš Zachar 2020-05-04 07:38:38 UTC
Still seeing similar vte.sh in Fedora 32

Comment 21 Ben Cotton 2021-04-29 15:44:15 UTC
This message is a reminder that Fedora 32 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 32 on 2021-05-25.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '32'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 32 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 22 Ben Cotton 2021-05-25 14:56:01 UTC
Fedora 32 changed to end-of-life (EOL) status on 2021-05-25. Fedora 32 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 23 Adam Williamson 2021-05-25 16:12:18 UTC
Still appears to be the case in Rawhide. Nothing has changed. upstream bug is still stuck in an argument in 2017.

Can someone please revisit this and do something about it finally?

Comment 24 Kalev Lember 2021-05-27 12:45:05 UTC
Sorry, I don't know anything about this, this is all downstream patches that Rishi maintains.

Comment 25 Christian Persch 2021-05-28 16:44:34 UTC
This has nothing to do with fedora's vte patches; this is upstream. -> https://gitlab.gnome.org/GNOME/vte/-/issues/37 . Since bash apparently now has the required functionality, someone can submit a patch to vte to use it.

Comment 26 Ben Cotton 2021-08-10 12:44:28 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 35 development cycle.
Changing version to 35.

Comment 27 Christian Persch 2022-01-07 14:47:36 UTC
This is fixed upstream since vte 0.66 (see https://gitlab.gnome.org/GNOME/vte/-/issues/37) but the distribution's setup needs changes for this, too (see the upstream bug).

Comment 28 Debarshi Ray 2022-06-15 18:05:17 UTC
This bug, as originally reported has two parts.

(In reply to Adam Williamson (Fedora) from comment #0)
> /etc/bashrc has this:
> 
>     case $TERM in
>     xterm*|vte*)
>       if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
>           PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
>       elif [ "${VTE_VERSION:-0}" -ge 3405 ]; then
>           PROMPT_COMMAND="__vte_prompt_command"
>       else
>           PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}"
> "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
> 
> then /etc/profile.d/vte.sh has:
> 
> case "$TERM" in
>   xterm*|vte*)
>     [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command" 
>     [ -n "$ZSH_VERSION"  ] && precmd_functions+=(__vte_osc7)
>     ;;
> esac
> 
> first of all, why is this duplicated between the two? Seems unnecessary.

This first part has been effectively fixed since Fedora 35 because it was negatively impacting certain Toolbx containers:
https://pagure.io/setup/pull-request/23

... and I filed a clean-up as a follow-up:
https://pagure.io/setup/pull-request/37

Comment 29 Debarshi Ray 2022-06-15 19:53:50 UTC
(In reply to Adam Williamson (Fedora) from comment #0)
> 
> Second, vte.sh doesn't incorporate any previous PROMPT_COMMAND. That means
> if you create a /etc/profile.d/prompt.sh (for e.g.) and set a custom
> PROMPT_COMMAND in it, it doesn't work, because vte.sh is included later and
> overrides it. You have to name your file so it comes alphabetically after
> vte.sh if you want to set a custom PROMPT_COMMAND.

As far as VTE is concerned, the second part was fixed in GNOME 41 (ie., Fedora 35 timeframe) (see comment 27):
https://gitlab.gnome.org/GNOME/vte/-/issues/37

... because Bash 5.1 made it possible to use PROMPT_COMMAND as an array:
https://lists.gnu.org/archive/html/info-gnu/2020-12/msg00003.html

That's essentially what we (as in GNOME) had long asked for.  See comment 2, comment 10 and comment 11.

However, VTE can only use PROMPT_COMMAND as an array if Fedora's Bash start-up scripts declare PROMPT_COMMAND as an array.  Currently that's not the case, and we need to get that done in 'setup'.

Comment 30 Debarshi Ray 2022-06-15 19:57:44 UTC
I am going to close this as CURRENTRELEASE, because this bug is against Fedora 35, and as far as VTE is concerned, barring clean-ups, it's fixed since F35.

Please file a bug against 'setup' to switch PROMPT_COMMAND to an array, and CC me.  Or, I may eventually end up submitting a pull request.  :P