Discussion:
[PATCH 1/3] less: use esc positive instead of esc normal
Bernhard Reutner-Fischer
2014-01-21 17:58:44 UTC
Permalink
.. to toggle esc negative off.
Simplify escape printing in m_status_print while at it.

function old new delta
m_status_print 200 212 +12
getch_nowait 308 312 +4
buffer_fill_and_print 178 182 +4
read_lines 805 808 +3
re_wrap 454 457 +3
buffer_print 666 665 -1
.rodata 148884 148883 -1
goto_match 125 122 -3
buffer_up 35 32 -3
less_getch 52 46 -6
buffer_down 86 78 -8
less_main 2599 2589 -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/7 up/down: 26/-32) Total: -6 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
miscutils/less.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/miscutils/less.c b/miscutils/less.c
index 60105f4..506231d 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -121,7 +121,7 @@
#define ESC "\033"
/* The escape codes for highlighted and normal text */
#define HIGHLIGHT ESC"[7m"
-#define NORMAL ESC"[0m"
+#define NORMAL ESC"[27m"
/* The escape code to home and clear to the end of screen */
#define CLEAR ESC"[H\033[J"
/* The escape code to clear to the end of line */
@@ -582,9 +582,10 @@ static void m_status_print(void)
cur_fline + 1, cur_fline + max_displayed_line + 1,
max_fline + 1);
if (cur_fline >= (int)(max_fline - max_displayed_line)) {
- printf("(END)"NORMAL);
+ printf("(END)");
if (num_files > 1 && current_file != num_files)
- printf(HIGHLIGHT" - next: %s"NORMAL, files[current_file]);
+ printf(" - next: %s", files[current_file]);
+ printf(NORMAL);
return;
}
percentage = calc_percent();
--
1.8.5.2
Bernhard Reutner-Fischer
2014-01-21 17:58:45 UTC
Permalink
Let ANSI escape sequences for color go through verbatim.
git diff HEAD^ --color=always | ./busybox_unstripped less -R

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
miscutils/less.c | 48 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/miscutils/less.c b/miscutils/less.c
index 506231d..cd553f6 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -98,7 +98,7 @@
//config: Enables "-N" command.

//usage:#define less_trivial_usage
-//usage: "[-E" IF_FEATURE_LESS_FLAGS("Mm") "Nh~I?] [FILE]..."
+//usage: "[-E" IF_FEATURE_LESS_FLAGS("Mm") "Nh~IR?] [FILE]..."
//usage:#define less_full_usage "\n\n"
//usage: "View FILE (or stdin) one screenful at a time\n"
//usage: "\n -E Quit once the end of a file is reached"
@@ -108,6 +108,7 @@
//usage: )
//usage: "\n -N Prefix line number to each line"
//usage: "\n -I Ignore case in all searches"
+//usage: "\n -R display color escape sequences"
//usage: "\n -~ Suppress ~s displayed past EOF"

#include <sched.h> /* sched_yield() */
@@ -142,7 +143,8 @@ enum {
FLAG_N = 1 << 3,
FLAG_TILDE = 1 << 4,
FLAG_I = 1 << 5,
- FLAG_S = (1 << 6) * ENABLE_FEATURE_LESS_DASHCMD,
+ FLAG_R = 1 << 6,
+ FLAG_S = (1 << 7) * ENABLE_FEATURE_LESS_DASHCMD,
/* hijack command line options variable for internal state vars */
LESS_STATE_MATCH_BACKWARDS = 1 << 15,
};
@@ -677,6 +679,19 @@ static void lineno_str(char *nbuf9, const char *line)
}
}

+static int is_ansi_color(const char *str)
+{
+ if (*str && *str++ == '\033' && *str == '[') {
+ unsigned nums = 3;
+ while (nums-- && *(++str)) {
+ if (*str == 'm')
+ return 1;
+ else if (!isdigit(*str))
+ return 0;
+ }
+ }
+ return 0;
+}

#if ENABLE_FEATURE_LESS_REGEXP
static void print_found(const char *line)
@@ -700,10 +715,18 @@ static void print_found(const char *line)
p += n;
str += n;
}
- n = strspn(str, controls);
- memset(p, '.', n);
- p += n;
- str += n;
+ if (option_mask32 & FLAG_R && is_ansi_color(str)) {
+ /* Let color sequences go through: \033[NNNm N is optional */
+ while (*str != 'm') {
+ *p++ = *str++;
+ }
+ *p++ = *str++;
+ } else {
+ n = strspn(str, controls);
+ memset(p, '.', n);
+ p += n;
+ str += n;
+ }
}
strcpy(p, str);

@@ -775,12 +798,19 @@ static void print_ascii(const char *str)
/* VT100's CSI, aka Meta-ESC. Who's inventor? */
/* I want to know who committed this sin */
*p++ = '{';
- else
+ else if (option_mask32 & FLAG_R && is_ansi_color(str)) {
+ /* Let color sequences go through: \033[NNNm N is optional */
+ while (*str != 'm') {
+ *p++ = *str++;
+ }
+ *p++ = *str++;
+ break;
+ } else
*p++ = ctrlconv[(unsigned char)*str];
str++;
} while (--n);
*p = '\0';
- print_hilite(buf);
+ printf(buf);
}
puts(str);
}
@@ -1617,7 +1647,7 @@ int less_main(int argc, char **argv)
/* TODO: -x: do not interpret backspace, -xx: tab also */
/* -xxx: newline also */
/* -w N: assume width N (-xxx -w 32: hex viewer of sorts) */
- getopt32(argv, "EMmN~I" IF_FEATURE_LESS_DASHCMD("S"));
+ getopt32(argv, "EMmN~IR" IF_FEATURE_LESS_DASHCMD("S"));
argc -= optind;
argv += optind;
num_files = argc;
--
1.8.5.2
Bernhard Reutner-Fischer
2014-01-22 09:52:39 UTC
Permalink
Let ANSI escape sequences for color go through verbatim.
git diff HEAD^ --color=always | ./busybox_unstripped less -R

v2: Also handle NNN;NNN;

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
miscutils/less.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 47 insertions(+), 9 deletions(-)

diff --git a/miscutils/less.c b/miscutils/less.c
index 506231d..5a06478 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -98,7 +98,7 @@
//config: Enables "-N" command.

//usage:#define less_trivial_usage
-//usage: "[-E" IF_FEATURE_LESS_FLAGS("Mm") "Nh~I?] [FILE]..."
+//usage: "[-E" IF_FEATURE_LESS_FLAGS("Mm") "Nh~IR?] [FILE]..."
//usage:#define less_full_usage "\n\n"
//usage: "View FILE (or stdin) one screenful at a time\n"
//usage: "\n -E Quit once the end of a file is reached"
@@ -108,6 +108,7 @@
//usage: )
//usage: "\n -N Prefix line number to each line"
//usage: "\n -I Ignore case in all searches"
+//usage: "\n -R display color escape sequences"
//usage: "\n -~ Suppress ~s displayed past EOF"

#include <sched.h> /* sched_yield() */
@@ -142,7 +143,8 @@ enum {
FLAG_N = 1 << 3,
FLAG_TILDE = 1 << 4,
FLAG_I = 1 << 5,
- FLAG_S = (1 << 6) * ENABLE_FEATURE_LESS_DASHCMD,
+ FLAG_R = 1 << 6,
+ FLAG_S = (1 << 7) * ENABLE_FEATURE_LESS_DASHCMD,
/* hijack command line options variable for internal state vars */
LESS_STATE_MATCH_BACKWARDS = 1 << 15,
};
@@ -677,6 +679,27 @@ static void lineno_str(char *nbuf9, const char *line)
}
}

+/* Determine if STR points to an ANSI color escape sequence of the form:
+ * \033[NNNm
+ * where NNN is
+ * - optional
+ * - can consist of one or more 3-digits, optionally separated by ';'
+ */
+static int is_ansi_color(const char *str)
+{
+ if (*str && *str++ == '\033' && *str == '[') {
+ unsigned nums = 4;
+ while (nums-- && *(++str)) {
+ if (*str == 'm')
+ return 1;
+ else if (*str == ';')
+ nums = 4;
+ else if (!isdigit(*str))
+ return 0;
+ }
+ }
+ return 0;
+}

#if ENABLE_FEATURE_LESS_REGEXP
static void print_found(const char *line)
@@ -700,10 +723,18 @@ static void print_found(const char *line)
p += n;
str += n;
}
- n = strspn(str, controls);
- memset(p, '.', n);
- p += n;
- str += n;
+ if (option_mask32 & FLAG_R && is_ansi_color(str)) {
+ /* Let color sequences go through: \033[NNNm N is optional */
+ while (*str != 'm') {
+ *p++ = *str++;
+ }
+ *p++ = *str++;
+ } else {
+ n = strspn(str, controls);
+ memset(p, '.', n);
+ p += n;
+ str += n;
+ }
}
strcpy(p, str);

@@ -775,12 +806,19 @@ static void print_ascii(const char *str)
/* VT100's CSI, aka Meta-ESC. Who's inventor? */
/* I want to know who committed this sin */
*p++ = '{';
- else
+ else if (option_mask32 & FLAG_R && is_ansi_color(str)) {
+ /* Let color sequences go through: \033[NNNm N is optional */
+ while (*str != 'm') {
+ *p++ = *str++;
+ }
+ *p++ = *str++;
+ break;
+ } else
*p++ = ctrlconv[(unsigned char)*str];
str++;
} while (--n);
*p = '\0';
- print_hilite(buf);
+ printf(buf);
}
puts(str);
}
@@ -1617,7 +1655,7 @@ int less_main(int argc, char **argv)
/* TODO: -x: do not interpret backspace, -xx: tab also */
/* -xxx: newline also */
/* -w N: assume width N (-xxx -w 32: hex viewer of sorts) */
- getopt32(argv, "EMmN~I" IF_FEATURE_LESS_DASHCMD("S"));
+ getopt32(argv, "EMmN~IR" IF_FEATURE_LESS_DASHCMD("S"));
argc -= optind;
argv += optind;
num_files = argc;
--
1.8.5.2
Bernhard Reutner-Fischer
2014-01-22 19:45:16 UTC
Permalink
On 22 January 2014 10:52:48 Bernhard Reutner-Fischer
<rep.dot.nop at gmail.com> wrote:

Ping. I See you just look at less.
Having both print_ASCII and print_found is pretty wastefull but beyond the
time I have right now.
OK to push as-is or do you want to do the -R below yourself?

Cheers,
Post by Bernhard Reutner-Fischer
Let ANSI escape sequences for color go through verbatim.
git diff HEAD^ --color=always | ./busybox_unstripped less -R
v2: Also handle NNN;NNN;
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
miscutils/less.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 47 insertions(+), 9 deletions(-)
diff --git a/miscutils/less.c b/miscutils/less.c
index 506231d..5a06478 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -98,7 +98,7 @@
//config: Enables "-N" command.
//usage:#define less_trivial_usage
-//usage: "[-E" IF_FEATURE_LESS_FLAGS("Mm") "Nh~I?] [FILE]..."
+//usage: "[-E" IF_FEATURE_LESS_FLAGS("Mm") "Nh~IR?] [FILE]..."
//usage:#define less_full_usage "\n\n"
//usage: "View FILE (or stdin) one screenful at a time\n"
//usage: "\n -E Quit once the end of a file is reached"
@@ -108,6 +108,7 @@
//usage: )
//usage: "\n -N Prefix line number to each line"
//usage: "\n -I Ignore case in all searches"
+//usage: "\n -R display color escape sequences"
//usage: "\n -~ Suppress ~s displayed past EOF"
#include <sched.h> /* sched_yield() */
@@ -142,7 +143,8 @@ enum {
FLAG_N = 1 << 3,
FLAG_TILDE = 1 << 4,
FLAG_I = 1 << 5,
- FLAG_S = (1 << 6) * ENABLE_FEATURE_LESS_DASHCMD,
+ FLAG_R = 1 << 6,
+ FLAG_S = (1 << 7) * ENABLE_FEATURE_LESS_DASHCMD,
/* hijack command line options variable for internal state vars */
LESS_STATE_MATCH_BACKWARDS = 1 << 15,
};
@@ -677,6 +679,27 @@ static void lineno_str(char *nbuf9, const char *line)
}
}
+ * \033[NNNm
+ * where NNN is
+ * - optional
+ * - can consist of one or more 3-digits, optionally separated by ';'
+ */
+static int is_ansi_color(const char *str)
+{
+ if (*str && *str++ == '\033' && *str == '[') {
+ unsigned nums = 4;
+ while (nums-- && *(++str)) {
+ if (*str == 'm')
+ return 1;
+ else if (*str == ';')
+ nums = 4;
+ else if (!isdigit(*str))
+ return 0;
+ }
+ }
+ return 0;
+}
#if ENABLE_FEATURE_LESS_REGEXP
static void print_found(const char *line)
@@ -700,10 +723,18 @@ static void print_found(const char *line)
p += n;
str += n;
}
- n = strspn(str, controls);
- memset(p, '.', n);
- p += n;
- str += n;
+ if (option_mask32 & FLAG_R && is_ansi_color(str)) {
+ /* Let color sequences go through: \033[NNNm N is optional */
+ while (*str != 'm') {
+ *p++ = *str++;
+ }
+ *p++ = *str++;
+ } else {
+ n = strspn(str, controls);
+ memset(p, '.', n);
+ p += n;
+ str += n;
+ }
}
strcpy(p, str);
@@ -775,12 +806,19 @@ static void print_ascii(const char *str)
/* VT100's CSI, aka Meta-ESC. Who's inventor? */
/* I want to know who committed this sin */
*p++ = '{';
- else
+ else if (option_mask32 & FLAG_R && is_ansi_color(str)) {
+ /* Let color sequences go through: \033[NNNm N is optional */
+ while (*str != 'm') {
+ *p++ = *str++;
+ }
+ *p++ = *str++;
+ break;
+ } else
*p++ = ctrlconv[(unsigned char)*str];
str++;
} while (--n);
*p = '\0';
- print_hilite(buf);
+ printf(buf);
}
puts(str);
}
@@ -1617,7 +1655,7 @@ int less_main(int argc, char **argv)
/* TODO: -x: do not interpret backspace, -xx: tab also */
/* -xxx: newline also */
/* -w N: assume width N (-xxx -w 32: hex viewer of sorts) */
- getopt32(argv, "EMmN~I" IF_FEATURE_LESS_DASHCMD("S"));
+ getopt32(argv, "EMmN~IR" IF_FEATURE_LESS_DASHCMD("S"));
argc -= optind;
argv += optind;
num_files = argc;
--
1.8.5.2
Sent with AquaMail for Android
http://www.aqua-mail.com
Denys Vlasenko
2014-01-27 12:18:07 UTC
Permalink
On Wed, Jan 22, 2014 at 8:45 PM, Bernhard Reutner-Fischer
On 22 January 2014 10:52:48 Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
Ping. I See you just look at less.
Having both print_ASCII and print_found is pretty wastefull but beyond the
time I have right now.
OK to push as-is or do you want to do the -R below yourself?
I'm trying to integrate this but there are problems.

For example, if we have "text <red> long text </red> text..." input line
and "long text" is wider than screen width, display is not correct.
Bernhard Reutner-Fischer
2014-01-21 17:58:46 UTC
Permalink
When looking at a file containing a word "foo", searching for foo
highlights the word. Now search for "asddsa" (no match), we are supposed
to clear the highlight of the previous foo, not key it off the validity
of the regex.
This makes the highlight disappear at least on the next redraw..

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
miscutils/less.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/miscutils/less.c b/miscutils/less.c
index cd553f6..6e187e6 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -822,7 +822,7 @@ static void buffer_print(void)

move_cursor(0, 0);
for (i = 0; i <= max_displayed_line; i++)
- if (pattern_valid)
+ if (num_matches)
print_found(buffer[i]);
else
print_ascii(buffer[i]);
--
1.8.5.2
Denys Vlasenko
2014-01-23 11:10:36 UTC
Permalink
On Tue, Jan 21, 2014 at 6:58 PM, Bernhard Reutner-Fischer
Post by Bernhard Reutner-Fischer
When looking at a file containing a word "foo", searching for foo
highlights the word. Now search for "asddsa" (no match), we are supposed
to clear the highlight of the previous foo, not key it off the validity
of the regex.
This makes the highlight disappear at least on the next redraw..
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
miscutils/less.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/miscutils/less.c b/miscutils/less.c
index cd553f6..6e187e6 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -822,7 +822,7 @@ static void buffer_print(void)
move_cursor(0, 0);
for (i = 0; i <= max_displayed_line; i++)
- if (pattern_valid)
+ if (num_matches)
print_found(buffer[i]);
else
print_ascii(buffer[i]);
I can not reproduce the bug: I follow your instructions
and everything works as expected:
highlights on all instances of "foo" disappeared
on the new redraw.
Denys Vlasenko
2014-01-23 09:56:26 UTC
Permalink
On Tue, Jan 21, 2014 at 6:58 PM, Bernhard Reutner-Fischer
Post by Bernhard Reutner-Fischer
.. to toggle esc negative off.
Why?
Post by Bernhard Reutner-Fischer
Simplify escape printing in m_status_print while at it.
Unfortunately, the result is code growth:

function old new delta
m_status_print 195 213 +18
Bernhard Reutner-Fischer
2014-01-23 19:24:49 UTC
Permalink
Post by Denys Vlasenko
On Tue, Jan 21, 2014 at 6:58 PM, Bernhard Reutner-Fischer
Post by Bernhard Reutner-Fischer
.. to toggle esc negative off.
Why?
Otherwise searching ruins my red and green git diff --color=always output.
Post by Denys Vlasenko
Post by Bernhard Reutner-Fischer
Simplify escape printing in m_status_print while at it.
Then just drop this last hunk, please.
Thanks,
Post by Denys Vlasenko
function old new delta
m_status_print 195 213 +18
Sent with AquaMail for Android
http://www.aqua-mail.com
Denys Vlasenko
2014-01-23 10:00:45 UTC
Permalink
On Tue, Jan 21, 2014 at 6:58 PM, Bernhard Reutner-Fischer
I am not really convinced about the size of the "Add -R" hunk as
it costs ~300b which is a bit too much for my taste. Anyone up to
rephrase/redo this? This sounds more like it should fit into <150b ;)
The whole thing was provoked by some systemd ctrl script outputting
color sequences, btw.
It is not okay in Unix to pipe escape sequences to a non-tty stdout.

I don't think the rest of Unix world needs to accommodate it.

Pottering's attempts to force his crap down our throats have to be
called out and resisted.
--
vda
Bernhard Reutner-Fischer
2014-01-23 19:28:09 UTC
Permalink
Post by Denys Vlasenko
On Tue, Jan 21, 2014 at 6:58 PM, Bernhard Reutner-Fischer
I am not really convinced about the size of the "Add -R" hunk as
it costs ~300b which is a bit too much for my taste. Anyone up to
rephrase/redo this? This sounds more like it should fit into <150b ;)
The whole thing was provoked by some systemd ctrl script outputting
color sequences, btw.
It is not okay in Unix to pipe escape sequences to a non-tty stdout.
I don't think the rest of Unix world needs to accommodate it.
Pottering's attempts to force his crap down our throats have to be
called out and resisted.
:)
Fix systemd then.
But apart from that I'd like to have a less that can display colors.


Sent with AquaMail for Android
http://www.aqua-mail.com
Harald Becker
2014-01-23 19:34:03 UTC
Permalink
Post by Bernhard Reutner-Fischer
But apart from that I'd like to have a less that can display
colors.
Me, too!

--
Harald
Laurent Bercot
2014-01-23 20:32:01 UTC
Permalink
Post by Bernhard Reutner-Fischer
Fix systemd then.
systemd is broken by design. The only way to fix it is to scrap it
and design another, non-broken init system from the ground up. And
it has already been done, several times. (By me, among others.)
Post by Bernhard Reutner-Fischer
But apart from that I'd like to have a less that can display colors.
Going down the slippery slope of rich text formatting usually ends up
in implementing a full HTML parser. :P
--
Laurent
Denys Vlasenko
2014-01-24 06:16:13 UTC
Permalink
On Thu, Jan 23, 2014 at 9:32 PM, Laurent Bercot
Post by Laurent Bercot
Post by Bernhard Reutner-Fischer
Fix systemd then.
systemd is broken by design.
I did not look too deeply into its design.
Unless there are serious design flaws I am not aware of,
the idea per se looks sensible.

Admit it - "traditional" SysV init is neanderthal.
Not merely "simple" (that's not a bad thing!) - but
awkward too.

My objection to Pottering's onslaught on Linux is not on the basis
that he writes buggy code.

My objection is that he tends to write *monolithic* code.
systemd requires dbus. systemd includes logging daemon.
I see a pattern here: if you want to use daemon A
(or *have to use* it for whatever reason),
you must also use B, C, and D.

It goes farther than that. Some things don't merely live
in tools which systemd requires (e.g. dbus). A lot of crap is
_in systemd_!

# ldd `which systemd`
linux-vdso.so.1 => (0x00007fff825fe000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fca4f97c000)
libsystemd-daemon.so.0 => /lib64/libsystemd-daemon.so.0 (0x00007fca4f778000)
libudev.so.1 => /lib64/libudev.so.1 (0x00007fca4f566000)
^^^^^^^^^^^^^
libwrap.so.0 => /lib64/libwrap.so.0 (0x00007fca4f35b000)
^^^^^^^^^^^^^
libpam.so.0 => /lib64/libpam.so.0 (0x00007fca4f14d000)
libaudit.so.1 => /lib64/libaudit.so.1 (0x00007fca4ef28000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007fca4ed23000)
libkmod.so.2 => /lib64/libkmod.so.2 (0x00007fca4eb0e000)
libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007fca4e8c8000)
librt.so.1 => /lib64/librt.so.1 (0x00007fca4e6c0000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fca4e4aa000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fca4e28d000)
libc.so.6 => /lib64/libc.so.6 (0x00007fca4decd000)
/lib64/ld-linux-x86-64.so.2 (0x00007fca4fec3000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fca4dc6f000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fca4da6a000)
libnsl.so.1 => /lib64/libnsl.so.1 (0x00007fca4d851000)
libattr.so.1 => /lib64/libattr.so.1 (0x00007fca4d64c000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fca4d426000)
libz.so.1 => /lib64/libz.so.1 (0x00007fca4d210000)

What the hell *TCP wrappers* or *udev* have to do with
*init binary*?????

He either does not understand why modularity is good,
or *likes* that his approach makes distributions use more
of the software developed by his team.

Another troubling aspect is gratuitous changes.
Like the one we see here: BAM! and he started feeding
**ANSI color escapes to a pager via pipe!**.
"Just because I can, if your pager doesn't understand it,
your problem".

I talked to him about it. He is not listening.
I'm telling you: this is not an oversight.
That's *his idea of how software should be developed*.
--
vda
Laurent Bercot
2014-01-24 10:13:18 UTC
Permalink
Post by Denys Vlasenko
Admit it - "traditional" SysV init is neanderthal.
Not merely "simple" (that's not a bad thing!) - but
awkward too.
Oh, I totally agree - I wrote s6, remember ? And I'm so much
more interested in getting the design and the code right than
in seeing it widely adopted that I didn't even take the time to
promote it - just the opposite of Lennart - which is obviously
a huge oversight. systemd was so obviously inane and insane to me
that I didn't even consider it could make it that big.
Post by Denys Vlasenko
My objection to Pottering's onslaught on Linux is not on the basis
that he writes buggy code.
My objection is that he tends to write *monolithic* code.
systemd requires dbus. systemd includes logging daemon.
That's exactly what I meant by "broken by design".
See http://skarnet.org/software/s6/why.html and
http://skarnet.org/software/s6/s6-svscan-not-1.html#systemd :)

Lennart's quest for change disregards not only the current
conventions (which is not a bad thing to do per se), but also the most
basic software design principles as well as the core of the Unix
philosophy. This guy should apply at Microsoft, they'd love him there.
Post by Denys Vlasenko
It goes farther than that. Some things don't merely live
in tools which systemd requires (e.g. dbus). A lot of crap is
_in systemd_!
(...)
What the hell *TCP wrappers* or *udev* have to do with
*init binary*?????
(...)
Amen, brother, amen.
But I'm afraid you and I will be preaching to the choir here.
It's not the busybox mailing-list that we need to convince,
it's the major Linux distributions. I have no idea how a piece
of software that I wouldn't give a D to as an undergraduate
student project made it into Fedora and Arch Linux, is threatening
the whole GNU ecosystem, and is making countless people waste
countless hours trying to integrate it while keeping a pretense
of modularity.

I'm not good at advocacy - waging political wars is bothersome
and tiresome to me, and writing good code is a much better use of
my time. But someone who is, and who has a tiny bit of sense of what
good engineering is, should definitely step up and expose the
systemd fraud, and I'm all willing, as I'm sure you are, to provide
the detailed technical arguments.
--
Laurent
Rich Felker
2014-02-02 15:56:15 UTC
Permalink
Post by Denys Vlasenko
On Thu, Jan 23, 2014 at 9:32 PM, Laurent Bercot
Post by Laurent Bercot
Post by Bernhard Reutner-Fischer
Fix systemd then.
systemd is broken by design.
I did not look too deeply into its design.
Unless there are serious design flaws I am not aware of,
the idea per se looks sensible.
The idea is not sensible. If I find time I'll write a short article on
why for ewontfix, but it basically amounts to:

1. Crash in pid #1 brings down the whole system, so it's not
acceptable to do anything complex in pid 1.

2. Inability to upgrade all the functionality that's been moved into
systemd without rebooting, due to the inability to kill and restart
pid #1. This cannot be fixed robustly even if systemd execs its own
new version due to certain technical issues (there are cases when it
might fail and thereby bring down the whole system, see point 1).

3. Massive attack surface for a privileged process due to the public
(dbus-based) interface it exposes. This is an unacceptable security
risk.

A lot of the things systemd wants to achieve are correct (e.g. correct
process lifetime management for daemons rather than racy pid files,
clean race-free device insertion and removal handling, ...) but it's
wrong to put them in the init process. They all can (and most already
have) been handled in the past by other modular tools. The latter did
not fail to catch on due to technical deficiencies but due to
extremely conservative distro and admin policies and the lack of a
Poettering-level propaganda machine attempting to force people to
switch.

Rich
Lauri Kasanen
2014-02-02 18:46:44 UTC
Permalink
Post by Rich Felker
Post by Denys Vlasenko
Post by Laurent Bercot
systemd is broken by design.
I did not look too deeply into its design.
Unless there are serious design flaws I am not aware of,
the idea per se looks sensible.
The idea is not sensible. If I find time I'll write a short article on
1. Crash in pid #1 brings down the whole system, so it's not
acceptable to do anything complex in pid 1.
I fully agree with your mail. FWIW, when I made point 1 in the past,
their response was that since they catch all signals (including segv,
ill), systemd will happily not crash, but go on its merry way. This of
course completely ignores that it cannot fix whatever caused the error,
and may go on to do wildly incorrect things due to it.

- Lauri
--
http://www.fastmail.fm - mmm... Fastmail...
Rich Felker
2014-02-03 03:22:47 UTC
Permalink
Post by Lauri Kasanen
Post by Rich Felker
Post by Denys Vlasenko
Post by Laurent Bercot
systemd is broken by design.
I did not look too deeply into its design.
Unless there are serious design flaws I am not aware of,
the idea per se looks sensible.
The idea is not sensible. If I find time I'll write a short article on
1. Crash in pid #1 brings down the whole system, so it's not
acceptable to do anything complex in pid 1.
I fully agree with your mail. FWIW, when I made point 1 in the past,
their response was that since they catch all signals (including segv,
ill), systemd will happily not crash, but go on its merry way. This of
course completely ignores that it cannot fix whatever caused the error,
and may go on to do wildly incorrect things due to it.
Well in principle it could re-exec itself from the signal handler, but
that brings us to my point 2: doing that is not robust. I don't even
think execve is entirely atomic with respect to success/failure at the
kernel level (e.g. it can fail to map the new VM after destroying the
old one due to resource exhaustion) but even if the kernel were
careful and allocated the new VM fully before destroying the old one
and atomically replacing it, there are fatal errors that can occur
before the program takes control after exec, at least in the
dynamic-linked case (allocation, mmap, etc. failures in the dynamic
linker). With musl we can guarantee no such prior-to-entry failures
exist for the static-linked case (except when thread-local storage is
used and allocation is needed to satisfy it), but glibc and uclibc do
not make such a guarantee as far as I know (and systemd wants to be
dynamic linked anyway).

Rich

walter harms
2014-01-24 08:24:23 UTC
Permalink
Post by Laurent Bercot
Post by Bernhard Reutner-Fischer
Fix systemd then.
systemd is broken by design. The only way to fix it is to scrap it
and design another, non-broken init system from the ground up. And
it has already been done, several times. (By me, among others.)
Post by Bernhard Reutner-Fischer
But apart from that I'd like to have a less that can display colors.
Going down the slippery slope of rich text formatting usually ends up
in implementing a full HTML parser. :P
Tex seems a more sophisticated system ;)

re,
wh
Lauri Kasanen
2014-01-24 11:10:17 UTC
Permalink
On 23 January 2014 11:01:05 Denys Vlasenko <vda.linux at googlemail.com>
Post by Denys Vlasenko
Pottering's attempts to force his crap down our throats have to be
called out and resisted.
:)
Fix systemd then.
But apart from that I'd like to have a less that can display colors.
Another "me too". Colors in less are useful with git etc, systemd
doesn't have to have something to do with it.

- Lauri
--
http://www.fastmail.fm - Does exactly what it says on the tin
Harald Becker
2014-01-24 12:14:38 UTC
Permalink
Post by Lauri Kasanen
Post by Bernhard Reutner-Fischer
But apart from that I'd like to have a less that can display
colors.
Another "me too". Colors in less are useful with git etc, systemd
doesn't have to have something to do with it.
... to clarify my "me too". I do not use systemd. I like to
create colored file lists and colored log lists to be viewed with
a pager. A simple textual pager, not a full fledged HTML Browser
or even text processor.

--
Harald
Loading...