Top
Best
New

Posted by speerer 17 hours ago

Decoding the obfuscated bash script on a Uniqlo t-shirt(tris.sherliker.net)
1301 points | 208 commentspage 8
lloydatkinson 15 hours ago|
P ./cool.sh: line 31: bc: command not found ./cool.sh: line 34: bc: command not found ./cool.sh: line 37: bc: command not found E ./cool.sh: line 31: bc: command not found ./cool.sh: line 34: bc: command not found ./cool.sh: line 37: bc: command not found

Very wow. Shame they assumed everyone has "bc"...

em500 15 hours ago||
Why would that be a shame? "bc" is a mandatory POSIX command, while /bin/bash isn't (/bin/sh is the standard).
greazy 15 hours ago|||
Which distro are you running? Perchance did you run the shell script in alpine Linux (docker)?
piacos_ 15 hours ago|||
it doesn't seem to be installed on my endeavouros laptop
lloydatkinson 14 hours ago|||
Debian.
cb321 4 hours ago||
There is a python3 variant in this thread [1], but if that is not "standard enough" (as someone else may have mentioned bash itself is not POSIX), this awk would also work { Warning - this awk is 1000s of times faster than the bash. So, you really probably want that sleep { and sure 100s of times faster yet may be possible. } }:

    #!/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.

[1] https://news.ycombinator.com/item?id=48830669

comradesmith 15 hours ago||
You are fun.
lloydatkinson 14 hours ago||
Are we really at the "redditor insult" type comments stage of HN now? There is nothing wrong with saying a piece of code is broken.
deciduously 13 hours ago|||
Broken seems a little hyperbolic, it has an implicit dependency on a standard POSIX tool.
lloydatkinson 13 hours ago||
I suppose, but my Debian didn’t seem to ship with it.
exabrial 10 hours ago||
(:(){ :|:& };:)

This seems to work pretty well

bryanrasmussen 16 hours ago|
Why does the shirt have an obfuscated bash script on the back?
Tiberium 16 hours ago||
Because it's by Akamai, the blog links to https://www.akamai.com/newsroom/press-release/uniqlo-adds-ne...
kay_o 16 hours ago||
Uniqlo frequently does collaborations. This was one with a tech company
wbh1 15 hours ago||
It's at least the second one that Akamai's done, although I like this newest one the most.

The old one was: https://www.uniqlo.com/us/en/products/E459561-000/00

pezezin 14 hours ago||
I have both of them and wear them to work regularly xD

The guy who founded the new political party Team Mirai also wears it frequently: https://en.wikipedia.org/wiki/Takahiro_Anno