←back to thread

412 points conanxin | 9 comments | | HN request time: 0.407s | source | bottom
1. pavlov ◴[] No.41085505[source]
The CLI has a massive blind spot in today’s operating systems: it knows nothing useful about events.

Yet events are the primary way anything happens on a computer, whether it’s a user system or a server.

replies(6): >>41085537 #>>41085570 #>>41086080 #>>41087545 #>>41088178 #>>41090695 #
2. fock ◴[] No.41085537[source]
huh? DBUS is very much a thing and has CLI-tooling?
3. nonrandomstring ◴[] No.41085570[source]
Annoying though it may be, you can run a program in the background that can write to your open terminal.

Just in userspace you have;

   dmesg -w

   tail -f /var/log/messages
There's also dbus to monitor on Linux systems and a lot of kernel hook tricks you can use to get a message pop up if an event happens.

Because it gets annoying to have a process splurge notification stuff to a term you are working in, that's why you have info-bars which many terminal emulators support.

4. skydhash ◴[] No.41086080[source]
In unix world, everything is a file, so you can poll the file waiting for something to happen. And there’s the whole signal thing and dbus exists.
replies(1): >>41086216 #
5. pavlov ◴[] No.41086216[source]
Yeah, these are the event paradigms that I meant by “nothing useful.”

Files are not a good abstraction for events. Signals are broken in many ways. And DBus is both extremely clunky to use and non-portable.

There isn’t a built-in event paradigm similar to how streams and pipes are an integral part of the Unix-style CLI.

replies(1): >>41086460 #
6. dandanua ◴[] No.41086460{3}[source]
> Files are not a good abstraction for events

Why is that? On the low level everything is a state of electronic cells. Files address those cells in a suitable fashion. Modern programming abstractions such as async/await are very simple, but fail miserably if you need something really complex and efficient.

7. anthk ◴[] No.41087545[source]
You mean, like entr triggering commands?
8. johnklos ◴[] No.41088178[source]
I can't even understand this. How does the CLI relate to events? Are you saying that all servers secretly have an invisible GUI and handle events there?

This just seems like an odd non sequitur.

9. dredmorbius ◴[] No.41090695[source]
That's the specific hole which Expect fills for scripting:

<https://en.wikipedia.org/wiki/Expect>

Much of modern operating systems is events-based and relies on polling for specific actions, devices connecting / disconnecting, etc. Linux device management is based on this, for example. There are numerous scripts which fire as a service is enabled or disabled (networking "ifup" and "ifdown" scripts, for example), or services are started / stopped. Systemd extends these capabilities markedly.

And of course there's a whole slew of conditional processing, beginning with init scripts, [], test, &&, ||, and specific conditional logic within shells, scripting, and programming languages.