In this section:
Mon, 31 Jul 2023
Rummaging around in the Internet Archive recently, I found a book in a language I couldn't recognize. Can you identify it? Here's a sample page:
I regret that IA's scan is so poor.
Sun, 30 Jul 2023
I'm about thirty-five years into Unix shell programming now, and I continue to despise it. The shell's treatment of whitespace is a constant problem. The fact that
doesn't work is a constant pain. The problem here is that if one of
the filenames is
and fail, saying
or worse there is a file named
To make it work properly you have to say
with the quotes around the
Now suppose I have a command that strips off the suffix from a filename. For example,
Ha ha, no, some of the files might have spaces in their names. I have to write:
Ha ha, no, fooled you, the output of
At this point it's almost worth breaking out a real language and using something like this:
I think what bugs me most about this problem in the shell is that it's so uncharacteristic of the Bell Labs people to have made such an unforced error. They got so many things right, why not this?
It's not even a hard choice! 99% of the time you don't want your
strings implicitly split on spaces, why would you?
For example they got the behavior of
Even if it was a simple or reasonable choice to make in the beginning,
at some point around 1979 Steve Bourne had a clear opportunity to
realize he had made a mistake. He introduced
and then run it:
except that doesn't work because
Oh, I see what went wrong, it thinks it got three arguments, instead
of two, because the elements of
No, the quotes disabled all the splitting so that now I got one argument that happens to contain two spaces.
This cannot be made to work. You have to fix the shell itself.
Having realized that
so that inside of
I deeply regret that, at the moment that Steve Bourne coded up this weird special case, he didn't instead stop and think that maybe something deeper was wrong. But he didn't and here we are. Larry Wall once said something about how too many programmers have a problem, think of a simple solution, and implement the solution, and what they really need to be doing is thinking of three solutions and then choosing the best one. I sure wish that had happened here.
Anyway, having to use quotes everywhere is a pain, but usually it works around the whitespace problems, and it is not much worse than a million other things we have to do to make our programs work in this programming language hell of our own making. But sometimes this isn't an adequate solution.
One of my favorite trivial programs is called
Many programs stick files into that directory, often copied from the
web or from my phone, and often with long and difficult names like
except ha ha, no I don't, because none of those works reliably, they all fail if the difficult filename happens to contain spaces, as it often does. Instead I need to type
which in a command so short and throwaway is a noticeable cost, a cost extorted by the shell in return for nothing. And every time I do it I am angry with Steve Bourne all over again.
There is really no good way out in general. For
The actual script is somewhat more reliable, and is written in Python, because shell programming sucks.
[ Addendum 20230731: Drew DeVault has written a reply article about
[ Addendum 20230806: Chris Siebenmann also discusses
Sat, 29 Jul 2023
I got a small but easy win last month. I have many wireless mice, and many of them are nearly impossible to tell apart.
Formerly, I would take my laptop somewhere, leaving the mouse behind, but accidentally take the dongle with me. Then I had a mouse with no dongle, but no way to match the dongle with all the other mice that had no dongle.
At best I could remember to put the dongles on a shelf at home, the mice on an adjacent shelf, and periodically attempt to match them up. This is a little more troublesome than it sounds at first, because a mouse that seems not to match any of the dongles might just be out of power. So I have to change the batteries in all the mice also.
Anyway, this month I borrowed Toph's paint markers and color-coded each mouse and dongle pair. Each mouse has a different color scribbled on its underside, and each dongle has a matching scribble. Now when I find a mystery dongle in one of my laptops, it's easy to figure out which mouse it belongs with.
The blue paint is coming off the dongle here, but there's still enough to recognize it by. I can repaint it before the color goes completely.
I had previously tried Sharpie marker, which was too hard to see and wore off to quickly. I had also tried scribing a pattern of scratches into each mouse and its dongle, but this was too hard to see, and there isn't enough space on a mouse dongle to legibly scribe very much. The paint markers worked better.
I used Uni Posca markers. You can get a set of eight fat-tipped markers for $20 and probably find more uses for them. Metallic colors might be more visible than the ones I used.
[ Addendum 20230730: A reader reports good results using nail polish, saying “It's cheap, lots of colors available and if you don't use gel variants it's pretty durable.”. Thanks nup! ]