Fix zsh parsing error on NetBSD #134
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The zsh-specific parameter expansion ${(%):-%x} introduced in commit 96e0ea2 causes a parse error on NetBSD where /bin/sh cannot parse this syntax, even though it is inside a zsh-only conditional block.
The error occurs because the shell must parse the entire script before execution, and NetBSD's /bin/sh fails when it encounters the zsh-specific syntax with: "Syntax error: Bad substitution".
Wrap the assignment in eval to defer parsing until runtime, when the script is actually running under zsh. This maintains the fix for the NO_FUNCTION_ARGZERO option while restoring compatibility with NetBSD's /bin/sh.
Tested on NetBSD 9.4 and 10.1 (without zsh installed) where the parsing error was reproducible and verified the eval wrapper resolves it. Also tested on other platforms (most without zsh) including multiple Linux distros, FreeBSD, OpenBSD, and macOS which were not affected before or after this fix.