You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
We're stuck with the current behaviour for backward compatibility reasons, at least in the 1.0 release series. We can consider changing this for 93u+m/1.1 and later.
diff --git a/src/cmd/ksh93/sh.1 b/src/cmd/ksh93/sh.1
index 295ec506f..4280eee59 100644
--- a/src/cmd/ksh93/sh.1+++ b/src/cmd/ksh93/sh.1@@ -3999,8 +3999,10 @@ or
commands.
.PP
The environment for any
-.I simple-command\^-or function+.IR simple-command\^ ,+except calls of functions declared with the+.IB name (\^)+syntax,
may be augmented by prefixing it with one or more variable assignments.
A variable assignment argument is a word of the form
.IR identifier=value .
I like that you've simply left the effect on the offending functions undefined. But I'll propose a variation on your fix. I think it reads a little more cleanly.
I've also tried to improve an adjacent doc problem: that while the example illustrates the point, the "equivalent" commands
are not always equivalent (e.g., if args includes $TERM, or cmd is a function that invokes cd or exit). The qualifier "as far as the above execution of cmd is concerned" works only if you squint at it really hard.
Anyway, here's my variation. I hope I'm not breaking protocol by proposing it here rather than going through git. I can do the latter if you want.
--- sh.1 2024-08-01 18:54:10.000000000 -0400
+++ sh.1a 2024-11-14 16:50:46.590591944 -0500
@@ -3973,7 +3973,10 @@
.PP
The environment for any
.I simple-command\^
-or function
+other than special built-in commands (those listed below that are marked with \fB\(dg\fR),
+or for any function that was not defined with the
+.IB name (\^)
+syntax,
may be augmented by prefixing it with one or more variable assignments.
A variable assignment argument is a word of the form
.IR identifier=value .
@@ -3985,11 +3988,7 @@
\fB(export \|\s-1TERM\s+1; \|\s-1TERM\s+1=450; \|cmd \|args)\fR
.RE
.PP
-are equivalent (as far as the above execution of
-.I cmd\^
-is concerned except for special built-in commands listed below \-
-those that are
-marked with \fB\(dg\fR).
+are roughly equivalent.
.PP
If the obsolete
.B \-k
To reproduce the bug:
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:
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 thefunction 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.
The text was updated successfully, but these errors were encountered: