Posted by speerer 16 hours ago
https://www.wired.com/2000/08/court-to-address-decss-t-shirt...
Very wow. Shame they assumed everyone has "bc"...
#!/usr/bin/awk -f
BEGIN {
# Split on spaces so multi-byte utf8 works
nText = split("♥ P E A C E ♥ F O R ♥ A L L", tmp, " ")
for (i = 0; i < nText; i++) text[i] = tmp[i + 1]
color0 = 12; color1 = 208 # xterm-256 color cube range
nColor = color1 - color0 # Could be a pretty gradient
w = ENVIRON["COLUMNS"]; if (w == "") w = 80
h = ENVIRON["LINES"]; if (h == "") h = 24
freq = 0.2
for (t = 0; 1; t++) {
x = int(w/2 + w/4*sin(t*freq) + 0.5) # x pos ~ sine
color = color0 + int((nColor*t)/h)%nColor # cycle colors
ch = text[t % nText] # cycle chars
printf("%*s\033[38;5;%dm%s\033[m\n", x, "", color, ch)
fflush()
# system("sleep 0.1") # awk has no builtin sleep
}
}
As to "bug reports", the T-shirt published script also fails with LC_ALL=C for me as mentioned else-thread.FWIW, I think ancient practice to reach for `bc` instead of `awk` or even the arithmetic built into shells often annoys. The only reason I keep `bc` installed at all is to compile Linux kernels. Someone had some patch set to Linux to eliminate this very dependency many years ago now.