102 points · by janvdberg · 3y ago · 59 comments
There were two models available. One model's units all looked cleaner than those of the other, so I picked up one of those.
I bought a cable (RS-232?) and plugged it in. It worked great for command line stuff, but pine (the email client) and pico looked off, with some parts of the screen being drawn over others. I knew nothing about termcap/terminfo. This was before Google (and even before Altavista). I spent hours trying different things (perhaps I got some pointers from helpful folks on a newsgroup?) and managed to improve the situation, but it never worked flawlessly.
Looking back, what I was doing was a lot of random stuff without much understanding. I will probably never know whether what I was trying to do was impossible, or whether I failed just because I didn't know what I was doing and had no systematic approach to editing the termcap file.
With multiplatform, CI/CD, cloud, Docker, etc. I spend way more of my time in a terminal than I used to.
I generally have four or five xterms in use on my average Desktop.
A curses-based text interface is a good substitute for some graphical programs where an addressable cursor is required. It's certainly faster and more light-weight.
Programming for text-based programs also should involve the use of various options given in the terminfo, but most of us are lazy and only cater for one or two main cases. (Hiding behind curses/ncurses as those libraries do the thinking for us.)
if is_a_tty():
# do…
else:
# fooStepping through 40 years of organic development by a bunch of different groups whose decisions were based on the limitations of the time is just not gonna happen. But if you don't trying to understand where we ended up will drive you mad. You just pick some closed subset of behaviors / features that exist where your programs run and hope.
Every time I also think of just making a wrapper for it, but I never do.
They are doing just fine. You can't expect them to learn 50 years of technical complexity in a few days and why there are so many different shells and how they behave differently.
edit: replaced debt by complexity
if(operation_failed)
make_operation_succeed(); import os
if os.isatty(1):
print("stdout is a tty")
else:
print("stdout is not a tty")
It really is that simple. Substitute the 1 for 0 when checking if stdin is a tty, and 2 if checking stderr[1] There's an ioctl involved, and it can fail for other reasons than "fd is not terminal", however all the reason for the operation to fail are good reasons to not proceed with terminal specific behavior.
if (! try_thing())
if (! try_thing_again())
if (! try_thing_a_third_time())
give_up();
... where the thing is something that should basically always work, and if it doesn't there's no good reason to expect that trying again will have a different result. The programmer who wrote this thought it was defensive coding and a good practice.I’m bookmarking this to come back and read through some of these resources.
If you’re interested in my own process, here are the video’s I recorded as I worked through this.
Part 1 - Building the command https://youtu.be/s4ggSklJKic
Part 2 - Installing it on a Raspberry Pi https://youtu.be/G968wOZGFGs
These are SRE type positions where strong systems knowledge and debugging skills are a requirement or at least a big plus.
If you're looking for strong diagnostic skills, then ask those questions geared to give you direct information as opposed to trying to weed it out from the answer to a vague high-level process description question. If the candidate has no idea why you're asking then any answer at all should be satisfactory.
And the open ended question is great because it allows candidate to showcase what they know. Have no idea how PTYs are allocated by kernel? No problem, you can talk how shells work.
Disclosure: I'm not an SRE
Things that do happen with some regularity like disk corruption should probably get focused on first.