bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Colored prompt + cmdline ending at right margin => no explicit newline


From: Egmont Koblinger
Subject: Colored prompt + cmdline ending at right margin => no explicit newline
Date: Sat, 18 Nov 2017 21:45:02 +0100

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -Wdate-time
-D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/bash-IrsGKQ/bash-4.4=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall -no-pie
-Wno-parentheses -Wno-format-security
uname output: Linux blacky 4.13.0-16-generic #19-Ubuntu SMP Wed Oct 11
18:35:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.4
Patch Level: 12
Release Status: release

Hi,

Type a command (such as "echo asdfgh....") that just reaches the right edge
of the terminal (the cursor wraps to the next line) and execute it.

Then, do any of these:
 - double click on the last word of the command, or the first word of its
output,
 - copy-paste across this line boundary to a graphical text editor,
 - resize the terminal horizontally if it supports rewrap-on-resize (such
as gnome-terminal or urxvt).

With a simple prompt such as PS1='address@hidden $ ' the result is as expected:
 - double-click highlighting stops at that line boundary,
 - copy-pasting reveals that there's an explicit newline there,
 - rewrap on resize does what's expected.

Running 'script' reveals that the cursor is actually moved up, then to the
right by 79 columns, the last letter of the command is repainted and an
explicit newline is added.

Let's do the same with a colored prompt, e.g. PS1='address@hidden
$\[\e[m\] '
 - double clicking selects across the line boundary,
 - copy-pasting doesn't insert an explicit linebreak,
 - rewrap on resize does silly things.

According to 'script', the cursor is moved upwards and then immediately a
newline is printed to move it back. This, at least in some popular/standard
terminal emulators I've tried now (xterm, urxvt, gnome-terminal) does not
cause that line to be terminated with a hard newline.

Could bash (readline?) please perform the "magic" of reprinting the last
character followed by an explicit newline, even in case of more complex
prompts?


thanks a lot,
egmont


reply via email to

[Prev in Thread] Current Thread [Next in Thread]