Hello world! (yet again)
<2026-05-08T18:06:00+03:00> :first:test:tech:meta:
Hello world!
Another introduction to the blog that I must write yet again. At least this time, I'll spare the reader of the agony of having to read an essay about the nature of a blog and how it is so transcendent beyond classical texts, and how the whole world has changed from it. I'm not that melodramatic, nor energetic enough to be that pretentious at the moment. Instead, I'll start this serial with an adequately charismatic and funny story about how I got things messed up, quick.
Why, you might ask? Because at the moment, a small mistake just cost me all the pages on the site. I had to rewrite every unique thing over again. I had written a bunch of scripts to automate the whole website, and now all I wanted was that every tag in export context be replaced by a link to that tag's index. So a simple sed command in the editor would've been enough, right?
# the regex has been omitted due to unnecessary complexity
# is what I would say if I was a COWARD, which I am not
#!/bin/bash
for i in $(find *.org blog/*.org)
do
sed -E '/^#\+FILETAGS/! s;:([a-z-]+);:@@html:<a href=\"/tag/\1\">\1</a>@@;g' \
$i > $i;
done
Notice that last line right there? How I pipe into the same file I'm opening? Well, in POSIX sh, when stdout is redirected into a file, the file clears up before the command even runs. This means that despite me thinking that sed was going to access the files, buffer the output, then place it there, I was not. 1> is simply not buffered. If you redirect it somewhere, it truncates the file to start writing there.
Thus, the sed command was searching for patterns in an empty file, and so that export trial was suspiciously fast. It didn't hit me until I looked at the website and found everything empty. No text besides the postamble(footer). I didn't put a git repo for my blog's content, I just never thought that I could've made a mistake and accidentally trashed all my effort.
Why write something so incompetent, even if you weren't thinking on all six cylinders when you interpreted that stream redirection command? Well, it was out of impatience. I went impatiently, not bothering to check the sed manpage. This was my punishment, for not ReadingTFM.
As the first lesson of this blog, what can we learn?
- RTFM, no matter what
- Keep backups of everything
- Think patiently and think well because
- Nothing can save you from heedlessness/stupidity
Isn't that just the best 4 obvious rules of thumb that I had violated all at once? It certainly is. The more you know…