avleen / bashttpd

A web server written in bash
MIT License
1.51k stars 199 forks source link

I removed the date command #17

Open m42a opened 12 years ago

avleen commented 12 years ago

Can you merge your changes with the latest code please, and fix the cut? I'd love to merge this :-)

m42a commented 12 years ago

Actually, with the new architecture, everything but the date stuff is fixed already. The current version should only have the date bits changed (and I think this'll work on older versions of bash).

ghost commented 12 years ago

Several things:

m42a commented 12 years ago

Have you tested printf with bash 3.2? I just don't want to issue another request that won't work for avleen.

And Re: the stat change, I'll agree it's inefficient (although not majorly so; it takes less than half a second to size-check a 700K text file) but not for that reason; we have to read the entire file into memory anyway since we're serving it up.

ab commented 12 years ago

What's wrong with using stat? I'd much rather use something that's O(1) rather than O(n) to calculate length. (Note that I also tested using bash's built-in strlen with ${#content}, and it is slower than wc for files of any appreciable size.)

m42a commented 12 years ago

Nothing is wrong with stat, but it's not built into bash (or guaranteed to exist at all, in fact).