this post was submitted on 27 Jun 2024
37 points (79.4% liked)

Linux

8038 readers
105 users here now

Welcome to c/linux!

Welcome to our thriving Linux community! Whether you're a seasoned Linux enthusiast or just starting your journey, we're excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let's dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!

Rules:

  1. Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.

  2. Be respectful: Treat fellow community members with respect and courtesy.

  3. Quality over quantity: Share informative and thought-provoking content.

  4. No spam or self-promotion: Avoid excessive self-promotion or spamming.

  5. No NSFW adult content

  6. Follow general lemmy guidelines.

founded 1 year ago
MODERATORS
 

This is kind of a rant, but mostly a plea.

There are times when BusyBox is the only tool you can use. You've got some embedded device with 32k RAM or something; I get it. It's the right tool. But please, please, In begging you: don't use it just because you're lazy.

I find BusyBox used in places where it's not necessary. There's enough RAM, there's more than enough storage, and yet, it's got BusyBox.

BusyBox tooling is absolutely aenemic. Simple things, common things, like - oh, - capturing a regexp group from a simple match are practically impossible. But you can do this in bash; heck, it's built in! But BusyBox uses ash, which is barely a shell and certainly doesn't support regexp matching with group capture. Maybe awk? Well, gawk lets you, with -oP, but of course BusyBox doesn't use GNU awk, and so you can't get at the capture groups because it doesn't support perl REs. It'd be shocking if BusyBox provided any truly capable tools like ripgrep, in which this would be trivial. I haven't tried BB's sed yet, because sed's RE escaping is and has always been a bizarre nightmarish Frankenstein syntax, but I've got a dime riding on some restriction in BB's sed that prevents getting at capture groups there, too.

BusyBox serves a purpose; it is intentionally barely functional; size constraining trumps all other considerations. It achieves this well. My issue isn't with BusyBox, it's with people using it everywhere when they don't need to, making life hell for anyone who's trying to actually get any work done in it.

So please. For the sanity of your users: don't reach for BusyBox just because it's easy, or because you're tickled that you're going to save a megabyte or two; please spare a thought for your users on which you are inflicting these constraints. Use it when you have to, because otherwise it doesn't fit. Otherwise, chose a real shell, at least bash, and include some tools capable of more than less than the bare minimum.

top 26 comments
sorted by: hot top controversial new old
[–] [email protected] 15 points 4 months ago (1 children)

There are certainly places where BusyBox makes a lot of sense. Could you give some examples of where you're seeing it out of place?

[–] [email protected] 18 points 4 months ago (1 children)

I preface this with a statement that I'm brand-loyal to gliNet products. Love them to bits. I love that they're based on OpenWRT, and that you can ssh into them. But their user space tooling stinks.

They have 500MB RAM. My home router has a current uptime of 24 days, and half the RAM is still free. It's hard to tell how much persistent storage is on the device, but there's at least 50MB free. They could have put something a little more capable on it. It's what I'm currently fighting with - I want to script it so my VPN exit node auto switches at random times to random nodes - and it's just frustrating with the onboard tooling.

This isn't the first time I've run into it; it's not frequent, but it's happened more than once, and I think it's just a sloppy, lazy decision someone made.

[–] [email protected] 10 points 4 months ago (1 children)

I know this might trigger you, but... Alpine Linux

[–] [email protected] 9 points 4 months ago (1 children)

You know, I've never had a problem with Alpine. Maybe it's that I'm choosing less minimal base images, but the tooling always seems sufficient, and adding extra packages is super easy. Or, maybe Alpine just builds a BusyBox with all the features turned on.

I'm pretty sure when I've logged into my Alpine based containers, I get Bash and not Ash. That solves, like, 70% of the problems right there. grep doesn't need to have good regexp support, because bash has it built-in.

[–] [email protected] 7 points 4 months ago (1 children)

Alpine comes with busybox. Yes, I'm pretty sure they turn on all the good features.

By the way, on which system you were using that not all the features are turned on?

[–] [email protected] 4 points 4 months ago (1 children)

A commercial product built on OpenWRT. I love the product I'm just frustrated they aren't using the resources available in the hardware.

[–] [email protected] 2 points 4 months ago (1 children)

I got OpenWRT on my home router and I've never had this issue. I guess I just never have that advanced of a use case for its command line.

You're also free to install bash (or other sh) if space allows.

[–] [email protected] 4 points 4 months ago (1 children)

Yeah, I need to figure that part out. I'm getting familiar with uci at the moment, but I need to dig into what package management is available. There's enough space to install bash -plenty if ash wasn't there - but probably not enough to compile bash on the device.

Anyway, my original post wasn't about OpenWRT. I'll get what I need to do done, one way it another. It's just that I keep (rarely, but mor than once) encountering these ultra-pared down BusyBoxen in places where it's not necessary to have ultra-minimalism.

Several people have responded already as if I'm complaining about OpenWRT; one even suggested I "learn Lua, dummy," because Lua is available in OpenWRT.

I'm not complaining about OpenWRT. I'm asking developers to think twice about micro-BB builds in their products. Does it really need to be that small?

[–] [email protected] 3 points 4 months ago* (last edited 4 months ago) (1 children)

Yeah I hear you. While I personally never fell like it's that severe of functional limitations, I am aware on how stripped down busybox is. I'm also aware that some systems lives off 4MiB of flash and 32MiB of memory, so if you ask that question, you might get the answer "yes, it is necessary".

Meanwhile, if you have the luxury to install bash (or other full-featured shell), then that's one option to consider. You seem lime you're familiar with UNIX shell, and Lua is a whole new language. The Lua interpreter that comes by default might be stripped down as well anyway.

[–] [email protected] 4 points 4 months ago (1 children)

I agree, there are places where a totally stripped down BB makes sense; I'm not arguing that. I'm arguing against stripped down BB when it isn't necessary.

Also: Lua is 1.536MB on my system. Bash is 1.1MB. I don't know how big ash is, because I didn't easily find the sources for it, but even if it were half the size of bash, replacing ash with bash would make the cost of adding bash only 0.6MB - a third of including Lua. If you think you have enough space for Lua, you probably have enough space for bash instead of ash.

And you be able to do normal scripting with proper regexp support and not forcing your users to learn another language just to hack together a small solution.

I want to thank you for a calm, reasoned, sympathetic discussion about something that's currently, actively irritating me and making my responses more... acidic... than they should be.

[–] [email protected] 1 points 4 months ago (1 children)

I do get where they're coming from with Lua. With luci (the web interface), Lua must be installed as it's a requirement. However, it might be the stripped down version as well (AFAIK). Also, if you know bash & coreutils already, it might be counterproductive to have to learn something new.

I'm just glad that I could help. It's not fun to get stuck in such technical roadblock.

[–] [email protected] 2 points 4 months ago

Yup!

On the OpenWRT issue, I ended up hacking a solution up in Lua, which won't help the next time I encounter an issue with a limited BB in something that isn't OpenWRT. And, in a month I won't remember the tiny bit of Lua I learned, because this is the first and probably last time I'll be forced to use it.

Nothing against Lua, per se; I'd just prefer to keep working with ubiquitous standards for simple stuff, and use strongly typed compiled languages for anything nontrivial.

[–] [email protected] 7 points 4 months ago (1 children)

anaemic* (Sorry, that bothered me for some reason.)

As for capture groups, you'll have to find another way. Perversely, perhaps BusyBox continues to be included on certain systems because they know that the extra space is required for the code that works around BB's shortcomings. That sounds asinine until you realise that "solving the problem properly" most likely leads to that one XKCD comic about the proliferation of competing standards.

At worst, multiple sizes of BusyBox itself.

[–] [email protected] 2 points 4 months ago

No worries on the spelling correction. I don't know why autocorrect let that through.

The regexp thing wouldn't bother me if there were at least one tool that could be used. On any standard POSIX system, there would be at least one way, and on most Linux distros, there's a half-dozen relatively simple, installed-by-default tools that can do it. Bash, if nothing else.

But it's like, in BB every tool excludes this ability. It's frustrating, and of it isn't regexp, it's something else.

[–] [email protected] 3 points 4 months ago

First thing I always do on a new Termux installation is setting up bash and GNU tools.