Bug 25390 - byobu: wrong PS1 / prompt definition causes linewrap problems (missing escape)
Summary: byobu: wrong PS1 / prompt definition causes linewrap problems (missing escape)
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 7
Hardware: All Linux
Priority: Normal major
Target Milestone: ---
Assignee: QA Team
QA Contact:
URL:
Whiteboard: MGA7-64-OK
Keywords: advisory, validated_update
Depends on:
Blocks:
 
Reported: 2019-08-31 18:50 CEST by Christian Lohmaier
Modified: 2019-10-23 23:08 CEST (History)
6 users (show)

See Also:
Source RPM: byobu-5.127-2.mga7.src.rpm
CVE:
Status comment:


Attachments

Description Christian Lohmaier 2019-08-31 18:50:02 CEST
Description of problem:
writing long command wider than your screen doesn't wrap into a new line, but instead puts cursor at the beginning of the same line.
Worse, after that there's an offset applied, making it nearly impossible to edit a previously entered long command.

Version-Release number of selected component (if applicable):
byobu 5.127 as of mageia 7

How reproducible:
100%

Steps to Reproduce:
1. run byobu-terminal 
2. type "echo longseriesofcharactersuntilyouhitendoflineanditwrapsaround" press enter 
   *) note that while typing it didn't start a new line while typing, but started to overwrite the prompt
3). recall the command by pressing <up> and shorten it using backspace
   *) note that there's an offset and it is unclear where the active cursor is in terms to the actual commandline


The cause is wrong PS1 prompt variable from 
  /usr/share/byobu/profiles/bashrc

PS1="${debian_chroot:+($debian_chroot)}\[\e[31m\]\$(byobu_prompt_status)\[\e[38;5;69m\]\u\[\e[38;5;214m\]@\[\e[38;5;167m\]\h\[\e[38;5;214m\]:\[\e[38;5;71m\]\w\[\e[38;5;214m\]\$(byobu_prompt_symbol)\e[00m\] "

note that the last control sequence (after $(byobu_prompt_symbol)) has an ending \], but no opening \[ marker. "\e[00m\]" should be "\[\e[00m\]" so bash knows that those symbols in between don't count to line-width/take no horizontal space.

complete fixed line:
PS1="${debian_chroot:+($debian_chroot)}\[\e[31m\]\$(byobu_prompt_status)\[\e[38;5;69m\]\u\[\e[38;5;214m\]@\[\e[38;5;167m\]\h\[\e[38;5;214m\]:\[\e[38;5;71m\]\w\[\e[38;5;214m\]\$(byobu_prompt_symbol)\[\e[00m\] "

Serverity major, as not being able to edit your commands is a major feature not working, and can be dangerous if you thing you edited some parts, but the cursor actually was active in a completely different area, resulting in a command executed that differs from what appears on screen.
Comment 1 Marja Van Waes 2019-09-01 08:34:34 CEST
Assigning to byobu's registered maintainer.

Assignee: bugsquad => rverschelde
CC: (none) => marja11

Comment 2 David GEIGER 2019-10-16 17:17:36 CEST
This issue was fixed upstream in 5.129 release.

https://github.com/dustinkirkland/byobu/pull/30

So please test byobu-5.129-1.mga7 in Core/Updates_testing repo.

CC: (none) => geiger.david68210

Comment 3 David GEIGER 2019-10-16 17:38:11 CEST
Assigning to QA,


Advisory:
========================

Unescaping colors in bash prompt causes problems with scrolling
history in bash prompt. you can see leftovers from previous
commands when going back by history.
All colors in command prompt should be escaped with [ ]

So this update fixes this issue escaping colors in bash prompt.

========================

Packages in 7/core/updates_testing:
========================
byobu-5.129-1.mga7.noarch.rpm

Source RPM: 
========================
byobu-5.129-1.mga7.src.rpm

Assignee: rverschelde => qa-bugs

Comment 4 Len Lawrence 2019-10-17 23:10:20 CEST
Installed byobu and checked the bashrc profile.

PS1="${debian_chroot:+($debian_chroot)}\[\e[31m\]\$(byobu_prompt_status)\[\e[38;5;69m\]\u\[\e[38;5;214m\]@\[\e[38;5;167m\]\h\[\e[38;5;214m\]:\[\e[38;5;71m\]\w\[\e[38;5;214m\]\$(byobu_prompt_symbol)\e[00m\] "
                                     ^
				     
$ byobu
〣 7 0:-*           224! 2h29m 0.69 20x1.2GHz 31.1G6% 43G46% 2019-10-17 21:48:31

with colours.  I did see some problems, in one case a continuously repeating command line.  Ctrl-^ killed that OK.

Updated the package and dependency.
Tail end of /usr/share/byobu/profiles/bashrc contains

PS1="${debian_chroot:+($debian_chroot)}\[\e[31m\]\$(byobu_prompt_status)\[\e[38;5;69m\]\u\[\e[38;5;214m\]@\[\e[38;5;167m\]\h\[\e[38;5;214m\]:\[\e[38;5;71m\]\w\[\e[38;5;214m\]\$(byobu_prompt_symbol)\[\e[00m\] "
                                      ^

showing that the correction has been made - insertion of '\[' before '\e'.

Logged out and in and typed:

$ byobu

0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
[B] Mageia 7      224! 1h41m 1.06 20x1.2GHz 31.1GB8% 43GB46% 2019-10-17 21:01:36
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9>
0*$ byobu-shell                               lcl@canopus 192.168.1.62 Menu:<F9Killed
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $ elasiobybu-db                                               
bash: elasiobybu-db: command not found                                          
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $ byobu-                                                      
bash: byobu-: command not found                                                 
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
lcl@canopus:byobu $                                                             
〣 7 0:-*           224! 2h41m 1.16 20x1.2GHz 31.1G6% 43G46% 2019-10-17 22:01:51

A lot of that is previous history.
$ exit 
worked.  Exited the byobu bash shell.

My impression is that the fault has been corrected but find configuration too complex and confusing to test this properly.
Giving it a tentative OK.

CC: (none) => tarazed25

Len Lawrence 2019-10-17 23:10:37 CEST

Whiteboard: (none) => MGA7-64-OK

Comment 5 Len Lawrence 2019-10-18 09:55:32 CEST
Comment on comment 4.
Something odd about the email received on [qa-bugs] list.
The two carets indicating the error and its correction appeared in entirely the wrong places so should be ignored.
Comment 6 Christian Lohmaier 2019-10-18 15:44:53 CEST
Not sure what you tested/what the output you pasted should mean. Also there should be no configuration needed at all to test this.

Test procedure:
broken version:
1) Open Termainal and run byobu (I use gnome terminal), or run byobu-terminal desktop entry (that does basically the same thing):
$ byobu

Result: get Colored prompt and status bar at the bottom. (byobu is a screen/tmux frontend, but none of those features needed to test the bug).

2) now type "echo this is a very long line continue typing until past the end of the screen"

Failure result #1: the line doesn't wrap to the next, but as you type it overwrites the start of the line. 

3) Hit enter, Command is executed as expected. Line is echoed to the terminal

4) use history (press "up" key)

Failure result #2: the edit cursor appears to be in the middle of the line. using "left" key to go to beginning of the line to do edits in the commandline is broken - you cannot really tell where in the line you are. And when you start typing the line starts shifting, adding to the confusion.

(type exit or ctrl+D to quit byobu)

Fixed version:
1) open byobu as above
2) type long command past end of screen like before

Correct result now: line breaks at end of screen to new line and no longer overwrites start of line

3) hit enter, command is executed as expected, line is echoed to the terminal
4) use history (press "up" key)

Correct result now: line is put to input line, with proper break across the new line, navigating/editing the command is working without issues, cursor corresponds to actual location in the command.

(can confirm fixed in testing package) - thx!
Comment 7 Thomas Andrews 2019-10-22 02:51:38 CEST
Thank you, Len and Christian. Validating. Advisory in Comment 3.

Keywords: (none) => validated_update
CC: (none) => andrewsfarm, sysadmin-bugs

Thomas Backlund 2019-10-23 19:39:59 CEST

Keywords: (none) => advisory
CC: (none) => tmb

Comment 8 Mageia Robot 2019-10-23 23:08:09 CEST
An update for this issue has been pushed to the Mageia Updates repository.

https://advisories.mageia.org/MGAA-2019-0169.html

Status: NEW => RESOLVED
Resolution: (none) => FIXED


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