GNU-style sed -i run with macOS's BSD sed
CommonBSD sed requires a suffix argument after -i, so your s/// becomes the suffix and the file name becomes the script.
Confirm
sed --version
An error such as illegal option on macOS (BSD sed has no --version); GNU sed prints its version
Fix
- Use the form that works on both: sed -i.bak 's/old/new/' FILE && rm FILE.bak.
- On macOS only: sed -i '' 's/old/new/' FILE.
- Or install GNU sed on the Mac (Homebrew calls it gsed) and use that in scripts that must behave like Linux.