107
you are viewing a single comment's thread
view the rest of the comments
[-] cr1cket@sopuli.xyz 8 points 2 days ago* (last edited 2 days ago)

Let me just drop my materials for a talk i've given about basically this topic: https://codeberg.org/flart/you_suck_at_shell_scripting/src/branch/main/you_suck.md

Mainly because: The linked article is all nice and dandy, but it completely ignores the topic of double brackets and why they're nice.

And also, and this is my very strong opinion: if you end up thinking about exception handling (like the mentioned traps) in shell scripts, you should stop immediately and switch to a proper programming language.

Shell scripts are great, i love them. But they have an area they're good for and a lot of areas where they aren't.

[-] MonkderVierte@lemmy.zip 4 points 1 day ago* (last edited 1 day ago)

Do you need POSIX compability?

  • If not, use bash-isms without shame

But call it a bash script then! Remember: #!/bin/sh is run by all kinds of shells; consider them POSIX. Bash is #!/bin/bash.

[-] cr1cket@sopuli.xyz 2 points 1 day ago

Uhm, yes. I noted exactly that as well.

Also bash is not always at /bin/bash :-)

[-] MonkderVierte@lemmy.zip 2 points 1 day ago* (last edited 1 day ago)

Yeah ok, /usr/bin/env then.

Edit: Or /bin/sh (oold convention) and check for bash.

[-] cr1cket@sopuli.xyz 3 points 1 day ago

Well, that won't work on openbsd (and probably freebsd), because non-default.stuff lands in /usr/local/bin.

For Linux you should be fine though.

this post was submitted on 11 Feb 2026
107 points (99.1% liked)

Programming

25521 readers
592 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS