Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
set temporary environment variables for builtins
- X-seq: zsh-users 29361
- From: Clinton Bunch <cdb_zsh@xxxxxxxxxxx>
- To: "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- Subject: set temporary environment variables for builtins
- Date: Sat, 16 Dec 2023 11:59:59 -0600
- Archived-at: <https://zsh.org/users/29361>
- List-id: <zsh-users.zsh.org>
- Reply-to: "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
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