Elektrine lite

← Feed

@ISO@lemmy.zip

2026-09-16 09:01 UTC

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.

Replies (2)

  • @psycotica0@lemmy.ca 2026-09-16 11:35

    I would argue the entire point of shell scripts is to coordinate running external programs, that’s what the shell is for, but I’m a dreamer. If I was just going to use the built-ins I’d use Python or Ruby or something. In this particular case I didn’t write the shell script, I was just debugging it because it broke on my system when I was running something. Also your implementation has a bug because dirname blah.png returns “.” 😉

    Open ##4724267

  • @vrighter@discuss.tchncs.de 2026-09-16 11:44

    if they claim to be posix compliant but aren’t, then it’s their bug, not their users’

    Open ##4724393