Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ksh Emulation Not Clearing Envariables



POSIX wants the envariable to persist across invocations
of the function "e"?  That seems...counter-intuitive.

I can't find it in POSIX now, but it's controlled by the option
posix_builtins. We could turn that off for ksh, but I'd like to know if
we really ever need to have it on by default.

http://www.opengroup.org/onlinepubs/009695399/utilities/ xcu_chap02.html#tag_02_09_05

Where we see

	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 Special Built-In
	Utilities.

One of those properties is:

	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.
Well...the variable assignment isn't occurring inside the function.
It's outside, put into the environment before the function is called.
Had the function looked like:

	e() {
		X=one
		echo $X
	}

	e ; echo "[$X]"

I would have expected to see

	one
	[one]

However, with this:

	e() {
		echo $X
	}

	X=one e ; echo "[$X]"

I'd expect to see

	one
	[]

I don't see how the spec can be read to mean "envariables
poked into a command shall persist across command invocations
when that command is a shell function."

Chet Ramey, ITS, CWRU chet@xxxxxxxxxxx http://tiswww.tis.cwru.edu/~chet/
Chris.



Messages sorted by: Reverse Date, Date, Thread, Author