Re:Filenames and Pathnames in Shell: How to Do It Correctly
by js2 on Monday June 19, 2023 @09:37PM
(#36398692)
To be clear: I agree with every recommendation in this article. I just find that writing POSIX-compliant shell is rarely needed.
I also write scripts for both Linux and macOS. They both provide bash, though macOS ships with an older version of it. So I use #!/bin/bash and stick to the older version that macOS provides. (Which often means ignoring the specific recommendations from shellcheck. e.g., macOS bash doesn't have readarray.)
What I have to be more careful of is differences in utilities like find, sed, etc.
I also write scripts for both Linux and macOS. They both provide bash, though macOS ships with an older version of it. So I use #!/bin/bash and stick to the older version that macOS provides. (Which often means ignoring the specific recommendations from shellcheck. e.g., macOS bash doesn't have readarray.)
What I have to be more careful of is differences in utilities like find, sed, etc.