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

Programmer Humor

20954 readers
2519 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
[–] Tungsten5@lemm.ee 12 points 22 hours 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…

[–] cm0002@lemmy.world 5 points 22 hours ago (4 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

[–] Tungsten5@lemm.ee 1 points 15 hours ago

Yeah I tried that, Claude with some C code. Unfortunately the Ai only took me from point A to point A. And it only took a few hours :D

load more comments (3 replies)
[–] Aceticon@lemmy.dbzer0.com 7 points 20 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.

[–] coldsideofyourpillow@lemmy.cafe 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.

[–] Akito@lemmy.zip 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)
[–] umbraroze@lemmy.world 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@programming.dev 11 points 1 day ago (4 children)

I consider python a scripting language too.

load more comments (2 replies)
[–] AI_toothbrush@lemmy.zip 18 points 1 day ago

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

[–] Irelephant@lemm.ee 7 points 22 hours ago (4 children)

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

load more comments (4 replies)
[–] SpaceNoodle@lemmy.world 52 points 1 day ago (9 children)

Clearly you don't write enough bash scripts.

load more comments (9 replies)
[–] perishthethought@lemm.ee 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)
[–] brokenlcd@feddit.it 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.

load more comments (1 replies)
[–] Gobbel2000@programming.dev 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.

[–] ClemaX@lemm.ee 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)
[–] Blackmist@feddit.uk 11 points 1 day ago (4 children)

Maybe applies more to regex, the write only language.

load more comments (4 replies)
[–] KazuchijouNo@lemy.lol 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 ›