this post was submitted on 05 Mar 2025
1548 points (99.0% liked)

Programmer Humor

21016 readers
1491 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
(page 2) 50 comments
sorted by: hot top controversial new old
[–] [email protected] 8 points 23 hours ago

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.

[–] [email protected] 12 points 1 day ago (1 children)

And I thought I was the only one… for smaller bash scripts chatGPT/Deepseek does a good enough job at it. Though I still haven’t tried VScode’s copilot on bash scripts. I have only tried it wirh C code and it kiiiinda did an ass job at helping…

[–] [email protected] 6 points 1 day ago (2 children)

AI does decently enough on scripting languages if you spell it out enough for it lol, but IMO it tends to not do so well when it comes to compiled languages

I've tried Python with VScode Copilot (Claude) and it did pretty good

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

That's because scripted languages are more forgiving in general.

[–] [email protected] 6 points 1 day ago (1 children)

I was chalking it up to some scripting languages just tending to be more popular (like python) and thus having more training data for them to draw from

But that's a good point too lol

[–] [email protected] 5 points 1 day ago

Both can be true, Python does have a lot of examples floating online.

load more comments (1 replies)
[–] [email protected] 18 points 1 day ago* (last edited 1 day ago) (17 children)

That's why I use nushell. Very convenient for writing scripts that you can understand. Obviously, it cannot beat Python in terms of prototyping, but at least I don't have to relearn it everytime.

[–] [email protected] 11 points 1 day ago (7 children)

Nu is great. Using it since many years. Clearly superior shell. Only problem is, that it constantly faces breaking changes and you therefore need to frequently update your modules.

load more comments (7 replies)
load more comments (16 replies)
[–] [email protected] 27 points 1 day ago (3 children)

There's always the old piece of wisdom from the Unix jungle: "If you write a complex shellscript, sooner or later you'll wish you wrote it in a real programming language."

I wrote a huge PowerShell script over the past few years. I was like "Ooh, guess this is a resume item if anyone asks me if I know PowerShell." ...around the beginning of the year I rewrote the bloody thing in Python and I have zero regrets. It's no longer a Big Mush of Stuff That Does a Thing. It's got object orientation now. Design patterns. Things in independent units. Shit like that.

[–] Kissaki 11 points 1 day ago (4 children)

I consider python a scripting language too.

load more comments (2 replies)
[–] [email protected] 18 points 1 day ago

Wait im not the only one? I think i relearned bash more times than i can remember.

[–] [email protected] 52 points 1 day ago (9 children)

Clearly you don't write enough bash scripts.

load more comments (9 replies)
[–] [email protected] 46 points 1 day ago (11 children)

I don't normally say this, but the AI tools I've used to help me write bash were pretty much spot on.

load more comments (11 replies)
[–] [email protected] 7 points 1 day ago (4 children)

It seems like it does stuff differently for the sake of it being different.

load more comments (4 replies)
[–] [email protected] 13 points 1 day ago (1 children)

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.

[–] [email protected] 7 points 1 day ago

Bash scripts survive because often times they are the easiest option on an abandoned server

[–] Gobbel2000 11 points 1 day ago (2 children)

So true. Every time I have to look up how to write a bash for loop. Where does the semicolon go? Where is the newline? Is it terminated with done? Or with end? The worst part with bash is that when you do it wrong, most of the time there is no error but something completely wrong happens.

[–] [email protected] 12 points 1 day ago* (last edited 1 day ago) (3 children)

It all makes sense when you think about the way it will be parsed. I prefer to use newlines instead of semicolons to show the blocks more clearly.

for file in *.txt
do
    cat "$file"
done

The do and done serve as the loop block delimiters. Such as { and } in many other languages. The shell parser couldn't know where stuff starts/ends.

Edit: I agree that the then/fi, do/done case/esac are very inconsistent.

Also to fail early and raise errors on uninitialized variables, I recommend to add this to the beginning of your bash scripts:

set -euo pipefail

Or only this for regular sh scripts:

set -eu

-e: Exit on error

-u: Error on access to undefined variable

-o pipefail: Abort pipeline early if any part of it fails.

There is also -x that can be very useful for debugging as it shows a trace of every command and result as it is executed.

load more comments (3 replies)
load more comments (1 replies)
[–] [email protected] 11 points 1 day ago (4 children)

Maybe applies more to regex, the write only language.

load more comments (4 replies)
[–] [email protected] 25 points 1 day ago (2 children)

Today I tried to write bash (I think)

I grabbed a bunch of commands, slapped a bunch of "&&" to string them together and saved them to a .sh file.

It didn't work as expected and I did not, at all, look at any documentation during the process. (This is obviously on me, I'll try harder next time)

load more comments (2 replies)
load more comments
view more: ‹ prev next ›