Skip to content

Conversation

@dun
Copy link
Contributor

@dun dun commented Jul 3, 2025

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.

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.
@felipec felipec merged commit 67504ee into felipec:master Jul 22, 2025
3 checks passed
@felipec
Copy link
Owner

felipec commented Jul 22, 2025

Thanks. I changed the title because this is a workaround. Ideally there should be a way to get the source on zsh with a more POSIXy syntax, but unfortunately it doesn't look like there is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants