diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2021-06-28 09:06:06 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2021-07-03 18:24:49 +0200 |
commit | 73fc6499d8416fc262c5d28688b91bf4580ab2b8 (patch) | |
tree | 34bbb4ab89f7c34561671454315a387d33b37483 | |
parent | 7e8d1f993588624473620b2b6c61e083e3d73512 (diff) | |
download | searxng-73fc6499d8416fc262c5d28688b91bf4580ab2b8.tar.gz searxng-73fc6499d8416fc262c5d28688b91bf4580ab2b8.zip |
[fix] utils/lib.sh: in a pipe, do not print ASCII escape code
In 2a12637 an ASCII escape code was added, such escape codes should not be
written to pipes (when the output is not a terminal).
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
-rwxr-xr-x | utils/lib.sh | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/utils/lib.sh b/utils/lib.sh index b75e3376b..185012c5d 100755 --- a/utils/lib.sh +++ b/utils/lib.sh @@ -78,9 +78,18 @@ required_commands() { # shellcheck disable=SC2034 set_terminal_colors() { - _colors=8 + # https://en.wikipedia.org/wiki/ANSI_escape_code + + # CSI (Control Sequence Introducer) sequences + _show_cursor='\e[?25h' + _hide_cursor='\e[?25l' + + # SGR (Select Graphic Rendition) parameters _creset='\e[0m' # reset all attributes + # original specification only had 8 colors + _colors=8 + _Black='\e[0;30m' _White='\e[1;37m' _Red='\e[0;31m' @@ -271,7 +280,7 @@ prefix_stdout () { echo -e "${prefix}$line" done) # some piped commands hide the cursor, show cursory when the stream ends - echo -en "\e[?25h" + echo -en "$_show_cursor" } append_line() { |