Commit Graph
3 Commits
Author SHA1 Message Date
Lauri Ojansivu 283e51eac0 Shell scripts: the root and releases/ scripts run on macOS too.
Started from zsh on macOS, a script gets bash 3.2 as /bin/bash and BSD
tools. Every .sh at the repository root and under releases/ was checked
with bash 3.2 and for GNU-only tool options; what failed:

- test-menu.sh: declare -A (bash 4) is a case function, runner_for, and
  an empty match list no longer trips set -u in bash 3.2.
- releases/ferretdb-latest-tag.sh: with no GitHub token, "${auth[@]}"
  was an unbound variable under set -u in bash 3.2; it uses
  ${auth[@]+...} as ferretdb-asset.sh already did.
- find-replace.sh: never worked anywhere ('$1' in single quotes searched
  for the text $1) and used GNU grep -Z and sed -i. It replaces literal
  text with perl now, skipping the directories find.sh skips.
- sha256sum (missing on older macOS) falls back to shasum -a 256 in
  release-x2.sh, repack-bundle-for-arch.sh, install-node-for-arch.sh and
  sandstorm-capnp-schemas.sh; -c works with both.
- sandstorm-capnp-schemas.sh: nproc falls back to sysctl hw.ncpu, and
  sed -i takes a .bak suffix (GNU and BSD alike) that is then removed.
- sandstorm-slim-spk.sh: ln -sfT is ln -sfn, stat -c%s is wc -c.
- virtualbox/ipaddress.sh: ifconfig where there is no ip.

tests/macosShellPortability.test.cjs parses every bash script with
bash 3.2 when /bin/bash is 3.x, and fails on any of these shapes coming
back: associative arrays or mapfile, flock without a fallback, tar
--transform, a GNU-only sed -i, sha256sum / nproc / ip without a
fallback, ln -T or stat -c.

Thanks to xet7 !
2026-10-27 23:02:14 +02:00
Martin Rys 7dc4d9bb71 Swap deprecated egrep for grep -E
also remove some extra whitespace in MD doc
2024-05-06 11:19:59 +02:00
Lauri Ojansivu bda49ed609 Add find-replace.sh script. 2020-06-17 20:28:22 +03:00