summaryrefslogtreecommitdiffstats
path: root/src/shared/pretty-print.c
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-03-02 04:45:02 +0100
committerMike Yuan <me@yhndnzj.com>2024-03-02 04:50:34 +0100
commit6283f873fb4a448adb99d0b1a3d994a35f79a973 (patch)
treea5d806c672e1e5ef773d1ca8495c38bf4bae7d14 /src/shared/pretty-print.c
parentman: fix typo (diff)
downloadsystemd-6283f873fb4a448adb99d0b1a3d994a35f79a973.tar.xz
systemd-6283f873fb4a448adb99d0b1a3d994a35f79a973.zip
shared/pretty-print: print color sequence only when needed
Follow-up for 71cb203a6ea6de409c6b9c042feda2ff655101e9
Diffstat (limited to 'src/shared/pretty-print.c')
-rw-r--r--src/shared/pretty-print.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/shared/pretty-print.c b/src/shared/pretty-print.c
index 543a9ebdcb..af44bb2ca2 100644
--- a/src/shared/pretty-print.c
+++ b/src/shared/pretty-print.c
@@ -465,7 +465,7 @@ int terminal_tint_color(double hue, char **ret) {
void draw_progress_bar(const char *prefix, double percentage) {
- fputs("\r", stderr);
+ fputc('\r', stderr);
if (prefix)
fputs(prefix, stderr);
@@ -474,12 +474,12 @@ void draw_progress_bar(const char *prefix, double percentage) {
size_t prefix_length = strlen_ptr(prefix);
size_t length = cols > prefix_length + 6 ? cols - prefix_length - 6 : 0;
- fputs(ansi_highlight_green(), stderr);
-
if (length > 5 && percentage >= 0.0 && percentage <= 100.0) {
size_t p = (size_t) (length * percentage / 100.0);
bool separator_done = false;
+ fputs(ansi_highlight_green(), stderr);
+
for (size_t i = 0; i < length; i++) {
if (i <= p) {