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

set temporary environment variables for builtins



I was playing around with date formats using print -P and tried to get the time in Paris.

This didn't work:

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

This does:

export TZ=Europe/Paris

print -P '%D{%Y%m%dT%H%M%S%z}'


but I have to unset/restore TZ afterwards.


I also tried:

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

It left me with TZ set.

I know this can be done with the date command, but it's one of those things that went from "Let's try this" to "Surely, there's a way to do this"

Is this a bug or design decision?

echo $ZSH_VERSION $ZSH_PATCHLEVEL $OSTYPE
5.8 zsh-5.8-0-g77d203f linux-gnu

cat /etc/system-release
Rocky Linux release 9.3 (Blue Onyx)





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