aboutsummaryrefslogtreecommitdiff
path: root/games/kvlt
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-07-06 09:22:07 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-07-06 09:22:07 +1200
commit0bd5bb37a7ce7cb1be7a97fbb88d13371c6cea46 (patch)
treec2933b54c5ce36e4be4fed252a339ae218227989 /games/kvlt
parentCorrect substitution error (diff)
downloaddotfiles-0bd5bb37a7ce7cb1be7a97fbb88d13371c6cea46.tar.gz
dotfiles-0bd5bb37a7ce7cb1be7a97fbb88d13371c6cea46.zip
Rewrite of kvlt(6)
It turns out GNU sed doesn't support POSIX word boundaries [[:<:]],[[:>:]]. This leaves me with no compatible way to denote a word boundary. I shouldn't really be surprised. I've worked around this by padding the start and end of each line with a tilde, and then removing it again at the end of the script, which is not great but will have to do. It's preferable to having two-three versions of each of the word-boundary rules to support ^ and $ anchoring. This is probably the weirdest way anyone has ever learned sed.
Diffstat (limited to 'games/kvlt')
-rwxr-xr-xgames/kvlt45
1 files changed, 33 insertions, 12 deletions
diff --git a/games/kvlt b/games/kvlt
index 3090abde..755d3636 100755
--- a/games/kvlt
+++ b/games/kvlt
@@ -1,17 +1,38 @@
#!/bin/sed -f
# Type like a young black metal enthusiast
+
+# Lowercase to capitals
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
+
+# O->0, S->Z, U->V
y/OSU/0ZV/
-s,C\([^EH]\),K\1,g
-s,CE ,ZE ,g
-s,C$,K,g
-s, W, V,g
-s,^W,V,g
+
+# Pad the start and end of the line temporarily to work around GNU sed(1) not
+# respecting POSIX word boundaries, leaving us with no compatible options
+s/^/~/
+s/$/~/
+
+# -C[EI] -> -Z[EI] (naïve attempt at finding soft Cs)
+s,\([A-Z]\)C\([EI][^A-Z]\),\1Z\2,g
+
+# Remaining Cs (presumably hard ones) become Ks
+y/C/K/
+
+# -I- -> -Y-
s,\([A-Z]\)I,\1Y,g
-s,^THE ,DER ,g
-s, THE , DER ,g
-s,^OF ,OV ,g
-s, AND , VND ,g
-s, TRUE , TRV ,g
-s,^TRUE ,TRV ,g
-s,TRUE$,TRV,g
+
+# THE -> DER
+s,\([^A-Z]\)THE\([^A-Z]\),\1DER\2,g
+
+# OF -> 0V
+s,\([^A-Z]\)OF\([^A-Z]\),\10V\2,g
+
+# AND -> VND
+s,\([^A-Z]\)AND\([^A-Z]\),\1VND\2,g
+
+# TRUE -> TRV
+s,\([^A-Z]\)TRUE\([^A-Z]\),\1TRV\2,g
+
+# Remove the padding established above
+s/^~//
+s/~$//