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

Re: set temporary environment variables for builtins



Thanks.  That worked.

Still wondering why the standard syntax for setting a temporary environment variable doesn't work for builtins.

I don't think I'm unusual in expecting this to work:

TZ=Europe/Paris print -P '%D{%z}'

Granted this is much more likely something someone would use with TZ=UTC.

On 12/16/2023 12:53 PM, Lawrence Velázquez wrote:
On Sat, Dec 16, 2023, at 12:59 PM, Clinton Bunch wrote:
I also tried:

() { typeset -x TZ=Europe/Paris; print -P '%D{%Y%m%dT%H%M%S%z}' }

It left me with TZ set.
With GLOBAL_EXPORT enabled (which is the default), ''typeset -x''
acts like ''typeset -gx''.  Use ''local -x''.

	% typeset -p TZ
	typeset: no such variable: TZ
	% () { local -x TZ=Europe/Paris; print -P '%D{%z}' }
	+0100
	% typeset -p TZ
	typeset: no such variable: TZ





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