Skip to content

Commit

Permalink
refactor: remove ansi sequence from creeol when ansi=off (#4352)
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
pirpyn authored Oct 28, 2023
1 parent c51734f commit c0742b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lgsm/modules/core_messages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
# nl: new line: message is following by a new line.
# eol: end of line: message is placed at the end of the current line.
fn_ansi_loader() {
# carriage return.
creeol="\r"
if [ "${ansi}" != "off" ]; then
# echo colors
default="\e[0m"
Expand All @@ -29,9 +31,9 @@ fn_ansi_loader() {
darkgrey="\e[90m"
lightgrey="\e[37m"
white="\e[97m"
# erase to end of line.
creeol+="\033[K"
fi
# carriage return & erase to end of line.
creeol="\r\033[K"
}

fn_sleep_time() {
Expand Down

0 comments on commit c0742b2

Please sign in to comment.