This change allows strcuterizr.sh to be executed via any combination of nested / recursive symlinked files and directories.
Instead of relying on the readlink command's -f (and related) option, which is not readily available on macOS, it uses a combination of:
readlink (without the -f) to resolve terminal (non-directory) symlinks; and
cd -P to resolve all directory symlinks.
This has been tested (on GitHub hosted runners) with various symlink combinations on macOS (10.15, 11 and 12) and Ubuntu (18.04, 20.04 and 22.04).
I also took the opportunity to:
prevent potential accidental globbing and word splitting;
update the shebang to allow custom Bash installations (such as when macOS users have upgraded the terribly old Bash version that ships with the OS); and
set some best-practice error handling flags, so Bash doesn't barge on through unhandled error conditions.
This change allows
strcuterizr.sh
to be executed via any combination of nested / recursive symlinked files and directories.Instead of relying on the
readlink
command's-f
(and related) option, which is not readily available on macOS, it uses a combination of:readlink
(without the-f
) to resolve terminal (non-directory) symlinks; andcd -P
to resolve all directory symlinks.This has been tested (on GitHub hosted runners) with various symlink combinations on macOS (10.15, 11 and 12) and Ubuntu (18.04, 20.04 and 22.04).
I also took the opportunity to:
Cheers.