Sedtris: Tetris in sed
uuner.doslash.org
uuner.doslash.org
Does HN use the URL as a primary key or something else?
* Please correct me if I'm wrong!
Also, it's all too easy for a good post to get buried by a bunch of lame submissions, then fall off the new page before getting enough upvotes. It'd probably be worth making submissions cost a few points karma; the current system blindly rewards submitting anything others are likely to post.
http://www.catonmat.net/blog/sed-one-liners-explained-part-o...
Personally one of my favorite article series that I have written.
wget http://uuner.doslash.org/forfun/sedtris.sed && curl http://uuner.doslash.org/forfun/sedtris.sh | bash
With sh, it infinitely prints out
[: 48: unexpected operator
read: 48: Illegal option -s0: https://secure.wikimedia.org/wikipedia/en/wiki/Debian_Almqui...
Actually it is (sadly) the major reason, but not the only one:
The Debian policy manual has long mandated that "shell scripts specifying '/bin/sh' as interpreter must only use POSIX features"; in fact, this requirement has been in place since well before the inception of the Ubuntu project. Furthermore, any shell scripts that expected to be portable to other Unix systems, such as the BSDs or Solaris, already honoured this requirement. Thus, we felt that the compatibility impact of this change would be minimal. [1]
Personally I think that assuming nothing but POSIX is a more compelling reason than efficiency.
I was left wondering whether the game speeds up, though, and if so, how it works. Anyone know?
The helper bash script gives it input once a second.
It uses the "read" command to check for input from you, and it will wait 1 second. If it gets no input it sends the sed program an enter.
Unfortunately "read" can not have timeouts less than a second (it doesn't support fractions of a second).
If you want, you could replace "read" with a different program that accepts shorter timeouts. And presumably you could have the bash script slowly decrease the timeout.