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

Re: print builtin preceded by parameter assignment



On Wed, 2019-04-10 at 14:55 +0200, Vincent Lefevre wrote:
> It seems that the print builtin doesn't take into account a change
> of the environment with a parameter assignment. For instance:
> 
> cventin% zsh -c 'TZ=UTC print -P "%D{%c}"'
> 2019-04-10T14:53:50 CEST
> cventin% zsh -c 'export TZ=UTC; print -P "%D{%c}"'
> 2019-04-10T12:53:53 UTC
> 
> Is there any (undocumented?) reason or is this a bug?

It's certainly the case that such assignments only go into the
environment, and aren't processed within the shell.

I *think* this is standard behaviour:

http://pubs.opengroup.org/onlinepubs/9699919799/

2.9.1 specifies that unless the command is a special builtin utility,
the "current execution environment" is not affected by the assignment;
the value is simply exported.  I'd certainly assume the time zone seen
by % escapes is part of the current execution environment.  Neither
print (obvioussy) nor echo are special builtin utilities.

As this is a standard, I may simply have misread it.

pws



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