4 ms·
Everyone should try and read busybox. It’s a fairly complete implementation of a normal “unix” user space without the libc. Most commands are completely contain
by swiley 7y ago
Everyone should try and read busybox. It’s a fairly complete implementation of a normal “unix” user space without the libc. Most commands are completely contained in files less than a few thousand lines long and can be read through and completely understood in an afternoon. I personally use it for most things because of that even if some utilities are a little incomplete, being able to double check the source easily makes me feel like I won’t get surprised.
- thepete2 7y agoWhy not the GNU or BSD coreutils?
- dastx 7y agoPresuming because they are significantly bigger compared to busybox due to the limited feature set of busybox
- dana321 7y agoHad a quick look, found this little gem, a math evaluator with precedence. https://github.com/mirror/busybox/blob/master/shell/math.c https://github.com/mirror/busybox/blob/master/shell/math.c Some funny comments like "Think about it. * It makes sense."
- voldacar 7y ago> The lower 5 bits are the precedence, and 3 high bits are an ID unique across operators of that precedence. This is so cool. Nobody would write code like this today
- tachyonbeam 7y agoPeople wouldn't optimize a shell like that anymore, but people still do encode small pieces of information into integers using bitwise operations when compactness is an advantage. If you're dealing with a large data structure with tens of millions (or billions) of entries, compact encoding still trumps convenience, because memory bandwidth will often be the bottleneck. A data structure that would benefit from a compact encoding could be a compiler's intermediate representation, for example.
- userbinator 7y agoI was surprised that it's not recursive-descent/precedence-climbing, and that ~20% of the linecount is copyright/comments.
- swiley 7y agoYeah most things have a lot of comments. It’s very nice to read.