On Tue, 27 Mar 2001, Tom Oehser wrote:
> As an example of the advantages of lua, the old unrpm-- in awk was:
>
<...>
>
> granted, it has gone from 297 bytes to 351 bytes, but at a 120x
> performance boost!
I did a quick check on lua at CeBIT but haven't had time to form an
opinion yet. A quick note: changing the syntax slightly and moving lua
-> /bin makes unrpm 293 bytes: (add/remove more spaces to make it
more/less readble)
#!/bin/lua -f
if getargs()[3] {readfrom(getargs()[3])}
while 1{
b=read(1)
if !b {break}
if b=="\31"{
b=read(1)
if !b || b=="\139" {break}
}
}
if !b{
_ALERT("ERROR\n")
exit(-1)
}
writeto("|gzip -d|cpio -iuvmd")
write("\31\139")
buf=read(8192)
while buf{
write(buf)
buf=read(8192)
}
A bit closer to what <insert favorite deity> intended :-)
//Björnen.