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

Re: TMPDIR vs TMPPREFIX again



Except by the time any system initialization file is executing, TMPPREFIX has already been set by zsh itself.

Given the ubiquity of TMPDIR (it's used at least on BSD, Linux, and macOS) it seems like Zsh should honor it if set. I mean, if it just used the C library's `mkdtemp` instead of using a hard-coded path, it would get TMPDIR support for free..

On Fri, Aug 14, 2026 at 10:48 AM Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
 On 14/08/2026 15:28 BST Mark J. Reed <markjreed@xxxxxxxxx> wrote:
>
>
> How does TMPPREFIX get initialized? At least on my Mac, it's not set
> in the environment before zsh starts - but TMPDIR is, set by the OS.
> It seems like in that case zsh should initialize TMPPREFIX using
> TMPDIR instead of /tmp. If I were writing the initialization as a ?> shell command I'd probably go with this:
>
>  : "${TMPPREFIX:=${TMPDIR:-/tmp}/zsh}}"

The zsh source code doesn't treat TMPDIR as special at all, so this
looks to me like something to go in an initialisation file, indeed
it looks like it would make sense in a general system initialisation
file.

pws



--
Mark J. Reed <markjreed@xxxxxxxxx>


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