[Gllug] Hacker Attack, and a wild aside about version-controlled filesystems
Tethys
sta296 at astradyne.co.uk
Thu Jan 26 21:16:45 UTC 2006
Nix writes:
>> Z=$[(X=`tput cols`)*(Y=`tput lines`)];O=(X+1 X X-1 1);a(){ for((p=0;p<Z;p++));\
>> do z=$[y=p/X+1,x=p%X+1,0];q=${B[p]};[ $i ]||B[p]=$[RANDOM%3];for e in ${O[@]} \
>> ${O[@]//#/-};do(((j=p-e)>0))&&((0${B[j]}&&z++));done;c=\ ;((z==3))&&c=1;((z==2\
>> ))&&c=$q;echo -ne "\E[$y;${x}H$c";A[p]=$c;done;i=1;B=("${A[@]}");a;};a # ccooke
>
>... but now i have to decrypt this.
Interesting... it fills the screen semi-randomly, taking into
account the contents of the 8 neighbouring character cells. A
few things I didn't know before decrypting this:
You can use tput to query the current number of lines/columns.
I'd always assumed it would give you the fixed number listed in
the terminfo entry, rather than the current size of the window,
but it doesn't. I've always munged the output of "stty size" to
get this in the past.
You can perform arithmetic expansion with $[blah] -- I've always used
$((blah))
Shell variables are automatically dereferenced in arthmetic expansion,
even without a leading $ -- you can do c=$((c+1)), rather than c=$(($c+1)),
which I'd always done before.
Similarly, shell variables are also automatically dereferenced when used
as an array subscript -- you can say $blah[c] instead of $blah[$c] and
still have it work.
You can use # and % as anchors in string substitution (c.f. ^ and $ in
standard regular expressions)
Nice.
Tet
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list