* behavior of in-line variable assignments preceding functions, special built-ins
@ 2013-05-02 21:44 Bart Schaefer
2013-05-04 13:39 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2013-05-02 21:44 UTC (permalink / raw)
To: zsh-workers
I haven't worked out whether the change described below renders zsh's
assignment behavior non-conforming.
----------------------------------------------------------------------
(0001559) rhansen (reporter) - 2013-05-02 04:39
http://austingroupbugs.net/view.php?id=654#c1559
----------------------------------------------------------------------
Proposed changes:
In Issue7+TC1 XCU Section 2.9.1 at page 2339 lines 74354-74361, change:
If no command name results, or if the command name is a special
built-in or function, variable assignments shall affect the
current execution environment. Otherwise, the variable
assignments shall be exported for the execution environment of the
command and shall not affect the current execution environment
except as a side-effect of the expansions performed in step 4. In
this case it is unspecified:
* Whether or not the assignments are visible for subsequent
expansions in step 4
* Whether variable assignments made as side-effects of these
expansions are visible for subsequent expansions in step 4, or
in the current shell execution environment, or both
to:
Variable assignments shall be performed as follows:
* If no command name results, variable assignments shall affect
the current execution environment.
* If the command name is not a special built-in utility or
function, the variable assignments shall be exported for the
execution environment of the command and shall not affect the
current execution environment except as a side-effect of the
expansions performed in step 4. In this case it is
unspecified:
- Whether or not the assignments are visible for subsequent
expansions in step 4
- Whether variable assignments made as side-effects of these
expansions are visible for subsequent expansions in step
4, or in the current shell execution environment, or both
* If the command name is a standard utility implemented as a
function (see XBD Section 4.21), the effect of variable
assignments shall be as if the utility was not implemented as
a function.
* If the command name is a special built-in utility, variable
assignments shall affect the current execution environment.
Unless the 'set -a' option is on (see the 'set' special
built-in utility in Section 2.14), it is unspecified:
- Whether or not the variables shall gain the export
attribute during the execution of the special built-in
utility
- Whether or not export attributes gained as a result of the
variable assignments shall persist after the completion of
the special built-in utility
* If the command name is a function that is not a standard
utility implemented as a function, variable assignments shall
affect the current execution environment during the execution
of the function. It is unspecified:
- Whether or not the variable assignments shall persist
after the completion of the function
- Whether or not the variables shall gain the export
attribute during the execution of the function
- Whether or not export attributes gained as a result of the
variable assignments shall persist after the completion of
the function (if variable assignments persist after the
completion of the function)
In Issue7+TC1 XCU Section 2.9.5 at page 2347 lines 74675-74676, change:
When a function is executed, it shall have the syntax-error and
variable-assignment properties described for special built-in
utilities in the enumerated list at the beginning of Section 2.14.
to:
When a function is executed, it shall have the syntax-error
properties described for special built-in utilities in the first
item in the enumerated list at the beginning of Section 2.14.
In Issue7+TC1 XCU Section 2.14 at page 2356 lines 75105-75106, change:
2. Variable assignments specified with special built-in
utilities remain in effect after the built-in completes; this
shall not be the case with a regular built-in or other
utility.
to:
2. As described in Section 2.9.1, variable assignments preceding
the invocation of a special built-in utility remain in effect
after the built-in completes; this shall not be the case with
a regular built-in or other utility.
In Issue7+TC1 XCU Section 2.14 'export' at page 2372 lines 75584-75587,
change:
When no arguments are given, the results are unspecified. If a
variable assignment precedes the command name of export but that
variable is not also listed as an operand of export, then that
variable shall be set in the current shell execution environment
after the completion of the export command, but it is unspecified
whether that variable is marked for export.
to:
When no arguments are given, the results are unspecified.
(Note that this change reverts the changes made for issue #352, but the
changes for XCU Section 2.9.1 result in no net change in the specified
behavior of the 'export' special built-in utility.)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: behavior of in-line variable assignments preceding functions, special built-ins
2013-05-02 21:44 behavior of in-line variable assignments preceding functions, special built-ins Bart Schaefer
@ 2013-05-04 13:39 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2013-05-04 13:39 UTC (permalink / raw)
To: zsh-workers
On Thu, 2 May 2013 14:44:17 -0700 (PDT)
Bart Schaefer <schaefer@brasslantern.com> wrote:
> I haven't worked out whether the change described below renders zsh's
> assignment behavior non-conforming.
Nothing major, by the looks of things: it looks like a tightening up of
corner cases. I suppose we really need a .ztst to test it all
thoroughly, which shouldn't be hard to put together, although rather
dull.
It's not entirely clear to me whether "a standard utility implemented as
a function" applies if the user decides to create a function to take
over a builtin, but I would think that isn't the intention --- the
intention must surely be the user knows how the bare system works.
That's certainly my reading of the referenced section 4.21,
The system may implement certain utilities as shell functions (see XCU
Function Definition Command) or built-in utilities, but only an
application that is aware of the command search order (as described in
XCU Command Search and Execution) or of performance characteristics
can discern differences between the behavior of such a function or
built-in utility and that of an executable file
so I don't think that applies to zsh.
I notice it's already the case that functions behave like special
builtins in many respects. I can't remember ever checking that
explicitly (but the number of things I can't remember doing is
considerable).
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-04 13:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-02 21:44 behavior of in-line variable assignments preceding functions, special built-ins Bart Schaefer
2013-05-04 13:39 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).