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

Programmer Humor

21016 readers
1207 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
 
you are viewing a single comment's thread
view the rest of the comments
[–] SpaceNoodle@lemmy.world 52 points 1 day ago (3 children)

Clearly you don't write enough bash scripts.

[–] CrazyLikeGollum@lemmy.world 16 points 1 day ago (2 children)

Or scripts for basically any other variant of the Bourne shell. They are, for the most part, very cross compatible.

[–] Tinidril@midwest.social 10 points 1 day ago

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.

[–] BeigeAgenda@lemmy.ca 2 points 1 day ago (1 children)

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.

[–] YouAreLiterallyAnNPC@lemmy.world 4 points 1 day ago (1 children)

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 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.

[–] BeigeAgenda@lemmy.ca 1 points 1 day ago

Cool, good to know.

[–] Kissaki@programming.dev 6 points 1 day ago (1 children)

When I bash my head into a wall, does that count?

[–] SpaceNoodle@lemmy.world 3 points 1 day ago

Only if you scripted it

[–] Thcdenton@lemmy.world 5 points 1 day ago (1 children)
[–] Klear@sh.itjust.works 3 points 1 day ago

I've had enough of these motherfucking scripts on this motherfucking PC!