this post was submitted on 02 Oct 2023
1751 points (98.0% liked)

Programmer Humor

32175 readers
1154 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] Hazzia@discuss.tchncs.de 9 points 1 year ago (2 children)

I know that there are use cases for [ ] over [[ ]]. There have to be. Why in god's name would [ ] exist if there wasn't a reason to use it over [[ ]]? I'm obviously the one in the wrong by only ever using [[ ]], because [ ] would definitely be better in some type of situations that I'm just not seeing clearly. Right???

[–] hisbaan@lemm.ee 11 points 1 year ago (2 children)

I believe the reason is that bash is backwards compatible with sh and sh only has [ ], not [[ ]]

[–] float@feddit.de 6 points 1 year ago

[ is a binary (sometimes a symlink) in /usr/bin. It's /usr/bin/[ 🤓

[–] Number358@lemmy.world 5 points 1 year ago (2 children)

Solution: fuck backwards compatibility and use fish

Fish might be good for interactivity, but in terms of scripting, just go straight to python. It's not worth it.

[–] Cysioland@lemmygrad.ml 3 points 1 year ago

Fish is starting to get more POSIX compliant as of late, the error redirect is no longer ^ /dev/null but 2>/dev/null

[–] AffineConnection@lemmy.world 2 points 1 year ago

[[ is not a POSIX shell feature.