Skip to content

Commit c0742b2

Browse files
authored
refactor: remove ansi sequence from creeol when ansi=off (#4352)
When using "ansi"="off", the escape sequence \033[K is still present and tools that input from lgsm will get thoses bytes. This commit removes that. One side-effect if two prints are done without a line feed and the second is shorter than the first, then some unwanted character could remain. ``` echo -en "${creeol}foo/bar" echo -en "${creeol}foo" ``` * before : prints "foo" * after: prints "foo/bar"
1 parent c51734f commit c0742b2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lgsm/modules/core_messages.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
1010
# nl: new line: message is following by a new line.
1111
# eol: end of line: message is placed at the end of the current line.
1212
fn_ansi_loader() {
13+
# carriage return.
14+
creeol="\r"
1315
if [ "${ansi}" != "off" ]; then
1416
# echo colors
1517
default="\e[0m"
@@ -29,9 +31,9 @@ fn_ansi_loader() {
2931
darkgrey="\e[90m"
3032
lightgrey="\e[37m"
3133
white="\e[97m"
34+
# erase to end of line.
35+
creeol+="\033[K"
3236
fi
33-
# carriage return & erase to end of line.
34-
creeol="\r\033[K"
3537
}
3638

3739
fn_sleep_time() {

0 commit comments

Comments
 (0)