]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
terminal-util: use the right ANSI ST sequence
authorLennart Poettering <lennart@poettering.net>
Wed, 24 Dec 2025 07:00:39 +0000 (08:00 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 24 Dec 2025 08:40:43 +0000 (09:40 +0100)
There are multiple ways to encode ANSI ST, and we generally prefer ESC \
for it, for reasons explained in terminal-util.h. Hence, let's actually
follow this rule in the terminal reset logic, and use the ANSI_ST macro.

This will change the byte sequence generated (as it means we use ESC \
rather than BEL), but it doesn't change behaviour, as the two sequences
should be equivalent.

src/basic/terminal-util.c

index ce3a76bdd00f3fe468cced76e24d5756f76b624b..01c2bd375053b72b1b36809b97b3ab531cc608ec 100644 (file)
@@ -968,12 +968,12 @@ int terminal_reset_ansi_seq(int fd) {
                 return log_debug_errno(r, "Failed to set terminal to non-blocking mode: %m");
 
         k = loop_write_full(fd,
-                            "\033[!p"      /* soft terminal reset */
-                            "\033]104\007" /* reset colors via OSC104 */
-                            ANSI_NORMAL    /* reset colors */
-                            "\033[?7h"     /* enable line-wrapping */
-                            "\033[1G"      /* place cursor at beginning of current line */
-                            "\033[0J",     /* erase till end of screen */
+                            "\033[!p"              /* soft terminal reset */
+                            ANSI_OSC "104" ANSI_ST /* reset color palette via OSC 104 */
+                            ANSI_NORMAL            /* reset colors */
+                            "\033[?7h"             /* enable line-wrapping */
+                            "\033[1G"              /* place cursor at beginning of current line */
+                            "\033[0J",             /* erase till end of screen */
                             SIZE_MAX,
                             100 * USEC_PER_MSEC);
         if (k < 0)