2026-09-16 04:01 UTC
I had a problem literally today because some script was relying on a particular behaviour of dirname that was handled differently between uutils and GNU. It’s been fixed already in a newer version than the one I had, but it took me a long time to figure out what the heck was going on, because finding a missing expectation in a nested shell script is tough…
It was just mysteriously doing the wrong thing.
Replies (2)
-
@mesamunefire@piefed.social 2026-09-16 04:14
I remember it was a common problem between Mac is and Linux as well.
-
@ISO@lemmy.zip 2026-09-16 09:01
If you’re going to rely on shell scripts, you should stick to the built-in functionality of your shell as much as possible, as external commands can differ, or even be completely overridden, in random environments for a myriad of reasons. For example, use ${var%/*} instead of $(dirname $var). Forking out a whole OS process for such minuscule tasks is stupid anyway. This goes against la-la unix philosophy dreamy thoughts and beliefs, or portability fantasies. But it’s the right thing to do in the real world. And gives you at least some level of control over expected behavior.