Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 715526 - x11-libs/vte-0.58.2[-vanilla]: spurious characters printed in prompt with app-shells/bash-4
Summary: x11-libs/vte-0.58.2[-vanilla]: spurious characters printed in prompt with app...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Linux Gnome Desktop Team
URL: https://bugzilla.redhat.com/show_bug....
Whiteboard:
Keywords:
: 718674 (view as bug list)
Depends on: 719942
Blocks:
  Show dependency tree
 
Reported: 2020-03-30 21:37 UTC by Pacho Ramos
Modified: 2020-05-19 17:35 UTC (History)
8 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pacho Ramos gentoo-dev 2020-03-30 21:37:14 UTC
If I load 
. /etc/profile.d/vte-2.91.sh


in my .bashrc

I get strange characters sometimes, like:

 bash: ll: no se encontró la orden
pacho@dell-2017 ~ $ ll
bash: ll: no se encontró la orden
pacho@dell-2017 ~ $ ll
chobash: ll: no se encontró la orden
pacho@dell-2017 ~ $ ll
chobash: ll: no se encontró la orden
pacho@dell-2017 ~ $ ll
chobash: ll: no se encontró la orden
pacho@dell-2017 ~ $ ll
I refer to that "cho" before "bash...."

it looks to be caused by a Fedora patch (that we apply in Gentoo too): https://www.linuxquestions.org/questions/linux-software-2/ps1-prompt-inserts-text-777%3Bpreexec-4175665604/ https://github.com/TragicWarrior/libvterm/issues/147 https://github.com/alacritty/alacritty/issues/3105 https://bugzilla.redhat.com/show_bug.cgi?id=1780785 https://slashnix.com/linux/how-to-remove-the-return-code-from-the-terminal-prompt-in-centos-7/

-> https://bugzilla.redhat.com/show_bug.cgi?id=1805323

But I don't know how to fix the escapes in the resulting vte.sh file :/

Merging vte with USE "vanilla" fixes the problem as it doesn't apply Fedora patch
Comment 1 Pacho Ramos gentoo-dev 2020-04-01 12:00:51 UTC
This are the differences between vte.sh from 0.56 (that worked) and 0.58
--- vte-2.91.sh	2020-04-01 13:47:59.604843818 +0200
+++ /etc/profile.d/vte-2.91.sh	2020-04-01 13:48:52.537482004 +0200
@@ -54,12 +54,13 @@
   command="${command//;/ }"
   local pwd='~'
   [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
-  printf '\033]777;notify;Command completed;%s\033\\\033]0;%s@%s:%s\033\\%s' "${command}" "${USER}" "${HOSTNAME%%.*}" "${pwd}" "$(__vte_osc7)"
+  pwd="${pwd//[[:cntrl:]]}"
+  printf '\033]777;notify;Command completed;%s\033\\\033]777;precmd\033\\\033]0;%s@%s:%s\033\\%s' "${command}" "${USER}" "${HOSTNAME%%.*}" "${pwd}" "$(__vte_osc7)"
 }
 
 case "$TERM" in
   xterm*|vte*)
-    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command"
+    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command" && PS0=$(printf "\033]777;preexec\033\\")
     [ -n "$ZSH_VERSION"  ] && precmd_functions+=(__vte_osc7)
     ;;
 esac

The 
+  pwd="${pwd//[[:cntrl:]]}"

is an upstream change, the others are from Fedora patch updates, but I have checked their latest patch and it seems we are using the same as them
Comment 2 Mart Raudsepp gentoo-dev 2020-04-01 12:37:17 UTC
Any idea how I can reproduce this? Doesn't happen here
Comment 3 Pacho Ramos gentoo-dev 2020-04-01 13:59:19 UTC
Well, before knowing it was a problem with Fedora patch I reported to vte upstream, 
https://gitlab.gnome.org/GNOME/vte/-/issues/224

There I attached the output with script:
https://gitlab.gnome.org/GNOME/vte/uploads/dc356765bed174e0f39491bf48496a7a/typescript

I tried also with a simple .bashrc as the one I pasted in the bug report to discard it was caused by other things in my .bashrc. With that simple .bashrc I got all the script log. I think I don't have anything more special, my .bash_profile contains only:
# This file is sourced by bash for login shells.  The following line
# runs your .bashrc and is recommended by the bash info pages.
[[ -f ~/.bashrc ]] && . ~/.bashrc

And I have no .profile in my home :/

It is usually noticeable after multiple commands are run on a terminal. I tested it with gnome-terminal and vte terminal
Comment 4 Pacho Ramos gentoo-dev 2020-04-02 17:49:43 UTC
and PS0 has this value for me:
$ set |grep PS0
PS0=$'\E]777;preexec\E\\'

that leads to:
$ echo $PS0

$ echo $PS0
7
$ echo $PS0
mand
$ echo $PS0
tion
$ echo $PS0
tion
Comment 5 Pacho Ramos gentoo-dev 2020-04-22 20:01:47 UTC
*** Bug 718674 has been marked as a duplicate of this bug. ***
Comment 6 M8R-u38wij 2020-04-25 13:25:41 UTC
(In reply to Mart Raudsepp from comment #2)
> Any idea how I can reproduce this? Doesn't happen here

In x11-terms/mate-terminal and x11-terms/guake it happens if "Run command as login shell" checkbox is checked in Profile Preferences.
Comment 7 redneb 2020-04-27 02:33:58 UTC
I was able to fix this issue by replacing this

  PS0=$(printf "\033]777;preexec\033\\")

with this

  PS0=$(printf "\u009D777;preexec\u009C")

The inspiration came this bug [1]. Note that in that bug, the are talking about going the opposite direction. I suspect that the version /etc/profile.d/vte-2.91.sh that is installed by x11-libs/vte-0.58.2[-vanilla] is for a newer version of vte and my suggestion above will not work for these newer versions of vte.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1783802
Comment 8 Aisha Tammy 2020-04-27 05:08:13 UTC
i hate you fedora, this gave me nightmares during the day time.
@sam_c was nice enough to point me here

love you all for the salvation
Comment 9 Mart Raudsepp gentoo-dev 2020-04-27 12:24:08 UTC
It's just stol^Wborrowed from Fedora for some very useful features it provides.
That's how we have long-running command completion desktop notifications, "Set title" still possible for a tab, transparent background possibility and much more.

vte-2.91.sh is shipped by the same vte package, so they shouldn't be out of sync, unless you have your own vte.sh somewhere that's sourced instead.

What should be done here is the patchset compared with their 3.36 patchset - maybe the issue is already fixed there and we can backport.

Meanwhile I kept the 3.32 around of vte/gnome-terminal on purpose until this is figured out.
Comment 10 Alexander Tsoy 2020-04-27 19:29:44 UTC
Good news: I cannot reproduce this bug anymore after upgrading bash from 4.4 to 5.0
Comment 11 Alexander Tsoy 2020-04-28 14:24:12 UTC
Also I cannot reproduce this bug with vanilla bash-5.0. So it's hard to find how to fix this issue in bash-4.4 since bash lacks a proper commit history.
Comment 12 redneb 2020-04-28 14:34:25 UTC
Did you try my suggestion from #c7 with bash 5.0? It seem to work just fine in my system with bash 4.4.23 (the current stable).
Comment 13 Alexander Tsoy 2020-04-28 19:36:35 UTC
(In reply to redneb from comment #12)
Fedora switched from C1 to C0 controls for reason. There are people who launch terminals that doesn't support C1 controls from VTE-based terminals.
Comment 14 Mart Raudsepp gentoo-dev 2020-05-11 06:16:12 UTC
Has anyone hit the issue anymore with bash-5, which is by now stable on amd64 per dependent bug?
Comment 15 Pacho Ramos gentoo-dev 2020-05-13 21:38:56 UTC
I think it's solved
Comment 16 Mart Raudsepp gentoo-dev 2020-05-14 08:26:20 UTC
Alright. Bash stabilization is only missing hppa now, but we don't have stable vte on hppa, so should be all good then.