- cross-posted to:
- programmerhumor@lemmy.ml
- cross-posted to:
- programmerhumor@lemmy.ml
I still have to look up the exact syntax of ifs and whiles.
I’ve coded in bash for a while
I have a confession to make: Unless shell script is absolutely required, I just use Python for all my automation needs.
My google history hits for powershell for loop is is in the dozens.
Clearly you don’t write enough bash scripts.
Enough is enough
I’ve had enough of these motherfucking scripts on this motherfucking PC!
Or scripts for basically any other variant of the Bourne shell. They are, for the most part, very cross compatible.
I wrote a script to do backups on a ESXi it uses Busybox’s ASH, one thing I learned after spending hours debugging my scripts was that ASH does not support arrays so you have to do everything with temporary files.
There actually is an array in any POSIX shell. You get one array per file/function. It just feels bad to use it. You can abuse ‘set – 1 2 3 4’ to act as a proper array. You can then use ‘for’ without ‘in’ to iterate over it.
for i; do echo $i; done.
Use shift <number> to pop items off.
If I really have to use something more complex, I’ll reach for mkfifo instead so I can guarantee the data can only be consumed once without manipulating entries.
That’s the only reason I’ve ever done much of anything in shell script. As a network administrator I’ve worked many network appliances running on some flavor of Unix and the one language I can count on to be always available is bash. It has been well worth knowing for just that reason.
When I bash my head into a wall, does that count?
Only if you scripted it
I don’t normally say this, but the AI tools I’ve used to help me write bash were pretty much spot on.
Yeah, an LLM can quickly parrot some basic boilerplate that’s showed up in its training data a hundred times.
Yes, with respect to the grey bearded uncles and aunties; as someone who never “learned” bash, in 2025 I’m letting a LLM do the bashing for me.
Until the magic incantations you don’t bother to understand don’t actually do what you think they’re doing.
In fairness, this also happens to me when I write the bash script myself 😂
Sounds like a problem for future me. That guy hates me lol
Yeah fuck that guy
Yes, I have never wrote a piece of code that didn’t do what I thought it would before LLMs, no sir.
I wonder if there’s a chance of getting
rm -rf /*or zip bombs. Those are definitely in the training data at least.The classic
rm -rf $ENV/homewhere$ENVcan be empty or contain spaces is definitely going to hit someone one day
For building a quick template that I can tweak to my needs, it works really well. I just don’t find it to be an intuitive scripting language.
to be honest I agree and thought we would be using something more intuitive by now
Everything is text! And different programs output in different styles. And certain programs can only read certain styles. And certain programs can only convert from some into others. And don’t get me started on
IFS.I think the cool kids are using Nu now
I don’t write very small shell scripts because I am not a job destroyer.
Knowing that there is still a bash script i wrote around 5 years ago still running the entirety of my high scool lab makes me sorry for the poor bastard that will need to fix those hieroglyphs as soon as some package breaks the script. I hate that i used bash, but it was the easiest option at the time on that desolate server.
Bash scripts survive because often times they are the easiest option on an abandoned server
every control structure should end in the backwards spelling of how they started
Once you get used to it it is kind of fun.
Shame about
dothough.it could have been
notsince there’s notry.
No, Makefile syntax is more extreme.
I swapped from Make to Just: https://github.com/casey/just
Way better, IMO. Super simple logic, just as flexible.
Sure, but bash is more relatable, I think
I find
Makefileisn’t too bad, as long as I can stay away fromautomakeandautoreconf.
Wait im not the only one? I think i relearned bash more times than i can remember.
I’ve switched to nutshell imo. Bash is in need of a replacement
When I was finishing of my degree at Uni I actually spent a couple of months as an auxiliary teacher giving professional training in Unix, which included teaching people shell script.
Nowadays (granted, almost 3 decades later), I remember almost nothing of shell scripting, even though I’ve stayed on the Technical Career Track doing mostly Programming since.
So that joke is very much me irl.
Ever since I switched to Fish Shell, I’ve had no issues remembering anything. Ported my entire catalogue of custom scripts over to fish and everything became much cleaner. More legible, and less code to accomplish the same things. Easier argument parsing, control structures, everything. Much less error prone IMO.
Highly recommend it. It’s obviously not POSIX or anything, but I find that the cost of installing fish on every machine I own is lower than maintaining POSIX-compliant scripts.
Enjoy your scripting!
I switched to fish a while back, but haven’t learned how to script in it yet. Sounds like I should learn
I love fish but sadly it has no proper equivalent of
set -eas far as I know.|| return;in every line is not a solution.It’s the default on CachyOS and I’ve been enjoying it. I typically use zsh.
I wish I could but since I use bash at work (often on embedded systems so no custom scripts or anything that isn’t source code) I just don’t want to go back and forth between the two.
I’ve been meaning to check out
fish. Thanks for the reminder!Happy adventuring! ✨
If you’re going to write scripts that requires installing software, might as well use something like python though? Most Linux distros ship also ship with python installed
A shell script can be much more agile, potent, and concise, depending on the use case.
E.g. if you want to make a facade (wrapper) around a program, that’s much cleaner in
$SHELL. All you’re doing is checking which keyword/command the user wanted, and then executing the commands associated with what you want to achieve, like maybe displaying a notification and updating a global environment variable or something.Executing a bunch of commands and chaining their output together in python is surely much more cumbersome than just typing them out next to each other separated by a pipe character. It’s higher-level. 👍
If it’s just text in text out though, sure, mostly equivalent, but for me this is rarely the use case for a script.
I’m not anti bash or fish, I’ve written in both just this week, but if we’re talking about readability/syntax as this post is about, and you want an alternative to bash, I’d say python is a more natural alternative. Fish syntax is still fairly ugly compared to most programming languages in my opinion.
Different strokes for different folks I suppose.
It seems like it does stuff differently for the sake of it being different.
It’s more like bash did it one way and everyone who came after decided that was terrible and should be done a different way (for good reason).
Looking right at you -eq and your weird ass syntax
if [[ $x -eq $y ]]You better not look at powershell in that case :p
That was the point where I closed the bash tutorial I was on, and decided to just use python and
subprocess.run()-eq
Yeah, like infix, so between operands, but dashed like a flag so should come before arguments. Very odd.















