-
Notifications
You must be signed in to change notification settings - Fork 41
Description
To reproduce the bug:
f() { env; }
V=1 f | fgrep -x V=1
In all ksh93 versions I've tried up to and including Version AJM 93u+m/1.0.10 2024-08-01, this snippet prints nothing; the shell doesn't export V into the environment. This behavior contradicts the ksh93 man page:
The environment for any simple-command or function may be augmented by prefixing it with one or more variable assignments... Thus:
TERM=450 cmd args and (export TERM; TERM=450; cmd args)are equivalent...
In other words, the snippet should print V=1. This is what mksh, ksh88, and bash do.
This bug is only with functions defined with the name() syntax. Functions defined with the function name syntax behave correctly.
In fairness, I should note that POSIX section 2.9.1.2 allows either behavior. So it's not implausible to resolve this issue by just documenting the current inconsistent behavior in the man page. But I'd prefer consistency.