3 ms·
This is cool, I've used curses UIs to build various small things that need to be a) vaguely easy to use (so, complicated CLIs are out. oncalls need to be able t
by atomicnumber3 2y ago
This is cool, I've used curses UIs to build various small things that need to be a) vaguely easy to use (so, complicated CLIs are out. oncalls need to be able to use this at 3am while half their brain is still sleeping) and b) accessible over ssh because we have secure ssh access to these envs but ~nothing else.
So I love TUIs.
That said, I'm always a little puzzled about why people build these libraries in bash. Is it simply curiosity? Maybe, and if so, godspeed.
But if it's driven by pragmatism, let me assure the reader that if there are limits to the extents I will go to get python somewhere instead of writing even a somewhat nontrivial bash script, I have yet to find them. Not only is bash just kind of really annoying to program in, it's also nearly unethical to program in. Let me link the 2 I always link to when someone tells me they're "working on" a bash script.
Steam deleted my entire system (empty variable expansion): https://github.com/valvesoftware/steam-for-linux/issues/3671 https://github.com/valvesoftware/steam-for-linux/issues/3671
Bumblebee deletes /usr due to space: https://www.reddit.com/r/softwaregore/comments/2hsdo6/giant_bug_causing_usr_to_be_deleted_so_sorry/ https://www.reddit.com/r/softwaregore/comments/2hsdo6/giant_...
So I warn people: if you use python, you'll categorically avoid being the third entry in my list.
- gtirloni 2y agoPython is available virtually anywhere. I'd also not use Bash unless it's a very restricted situation. Every time I'm writing a shell script that's more than a page, a sense of imminent doom starts to dominate my soul.
- bongodongobob 2y agoNo it isn't. I don't know what kind of infrastructure you work on but I can't just go installing python on prod servers whenever I want to be able to run some random script.
- catlifeonmars 2y agoWhy are you running random scripts on prod servers? ;) :P
- gumby 2y agoSometimes the only way to investigate a problem. How can you even write a test case if you don't know what's going on?
- ElectricalUnion 2y agoI think that people that work on RHEL often assume python just "exists" everywhere because DNF has a python dependency, same for Debian, apt and perl.
- gtirloni 2y agoIn Kubernetes, you can attach a debug container with Python to a running pod. On VM's you can use pyenv for a local Python installation if you don't want to install it globally. In Docker vanilla, you can run another container with Python that uses the same namespaces (ipc, pid, network) as your other running container without Python. There are options. If your security team forbids Python for some reason, I would wonder why they are letting systems have bash/curl/etc on them.
- layer8 2y ago“Python” isn’t very well-defined. Which version? Which (installed) dependencies?
- gdevenyi 2y agoPython subprocess is terrible. Until they provide a much smoother interface for running other programs, bash will continue to dominate scripting.
- coderatlarge 2y agoPython is not available by default on macOS.
- panki27 2y agoPython also brings a wrapper for curses (atleast under *nix). Curses in itself needs so much boilerplate that I usually just go to the libraries rich or textual instead.
- ndsipa_pomu 2y agoBoth of those are examples of known footguns in BASH and it's easy enough to avoid them if you run your BASH scripts through ShellCheck and follow the recommendations.