Today I wrote a simple script to recursively convert reStructuredText files to asciidoc in the current folder:


for f in `find . -type f -name '*.rst'`
  pandoc -f rst -t asciidoc -o "${f%.rst}.adoc" $f
  rm $f

(Side note: pandoc doesn't preserve table of contents, so it's not a perfect conversion method ¯\_(ツ)_/¯)

I had done a trial run without the rm $f line, and it did what I wanted, so I added that line, made a backup of the folder I wanted to convert, then run the script again... the wrong terminal (my home directory) - whoops! I did wonder why this run took longer. Every rst file was now adoc.

Luckily, since everything is in version control, the fix was simple.

In the folder of each project that does use rst:

$ git reset --hard
$ git clean -f

** If there are uncommitted files with wanted changes you'd have to make a copy of them first.

A silly mistake like that could have caused way more damage, and yes, I'll try be more careful in the future, but it's easy to make mistakes. Thanks to git, this wasn't an issue at all.

\( '‿' )/