Sync’ up! … without getting drained

apr 20

The saddest script I ever wrote

When my Macbook OS got into a brambled state some years ago, I started to develop inside a ‘stateless’ docker container that runs Ubuntu.

Once in a while, things got bad, but there’s no worry because I could always just go back to my last state where all was clean and in working order.

This was a heck of a strange workflow, but at least I could have a rewind button for shoddy software that I installed, or even wrote myself.

(If memory serves, I think it was a sound driver to get ‘SoX’ working on OSX that got me into this strange world.)

A new hell

Docker seemed to introduce problems at every turn, but most the time, it wasn’t so much docker, but how I was using docker. When a problem came up, at least there was always a workaround. Years of this led me to a setup I’d call: ‘strange and unusual punishment OS.’ But hey, it all held together, and it was all deterministic.

One day about a year ago, I started using ed in place of vi and some incredibly unique behaviors crept into my life. Every time I thought I could tell my rubber duck the underlying issue, twenty-four hours later, I’d have a new conjecture. That said, here’s my current understanding of the bug:

When I work in my bind volume (shared by the docker container and OSX), and when I edit a file with ed and later compile it with Erlang’s erlc, the file’s source is stale whereby it uses some previous state of its contents at compile time. All of these three factors had to be present to create this confusing issue. (It should be noted it took months to arrive at this exact diagnosis.)

If I did the above outside of the bind volume, all would be well. If I saved the source-file with vi, all would be well. If I compiled ‘c’ source code that had been edited with ed, all would be well. Only Erlang source-code edited in ‘ed’ within the docker bind volume that would later be compiled would act this way.

Worse-er still

I created a workaround — because I would not be thwarted by crappy software — that I now consider to be the saddest lump of script every placed in a ‘bin’ path.

#!/bin/sh

csh -f `which rulr` # make a ruler appear
/usr/local/bin/ed $*
/usr/local/bin/vim -c 'wq' $*
exit 0 # just in case

I aliased a mapping to it (called it ‘wtfed’) with the following in my ‘.cshrc’:

alias eed 'wtfed'

… and voila, a twelve month pain-in-the-butt bug had been swept under the rug. Or maybe it’s more like I put its dead body in the downstairs freezer.

Yes, the state of software is broken, and I suppose it’s been fun to create solutions to remain sane despite this fact. However, this workaround was a new low. As soon as I whipped up this little hack, and it got my workflow back on a happy path, I heard a distant bugle start to play the ‘Taps’ melody in the back of my mind.