TMP/TEMP environment variable and /tmp

Hans-Bernhard Bröker HBBroeker@t-online.de
Wed Sep 16 19:27:20 GMT 2020


Am 16.09.2020 um 13:12 schrieb Thomas Wolff:
> Am 16.09.2020 um 13:04 schrieb marco atzeri via Cygwin:
>> On Wed, Sep 16, 2020 at 10:53 AM Kristian Ivarsson via Cygwin

>>> Does anyone know the rational with this behaviour and what can be 
>>> done to
>>> get hold of the (real) Windows TMP/TEMP environment-variable-values 
>>> (in a
>>> (hopefully) platform independent way) ?

>> so if you are making your custom tree, try to stick on that expectation
>> and have both directories.
> In general, you are free to set TMP to a directory of your choice, 
> that's the purpose of that variable, no need to sync it with some root.
> There is a comment in /etc/profile:
>    # TMP and TEMP as defined in the Windows environment
>    # can have unexpected consequences for cygwin apps,
> but it does not explain what consequences that might be; probably some 
> trouble with ACL/access permissions for temporary files.

Nowadays that would be $LOCALAPPDATA/Temp, or if you really insist, the 
content of /proc/registry/HKEY_CURRENT_USER/Environment/TMP (or TEMP), 
after similarly expanding environment variable references found in that.

The fact that getting Windows' idea of the user's TEMP directory is not 
immediately platform independent may well have been part of the 
rationale for not even trying that.

A bigger part of the reason may have been what the result of that 
platform-dependent query would have been, back when the decision had to 
be made.  For several releases you would have ended up with (your 
locally translated version of!) stupid old "Documents and Settings" as 
part of the pathname, and possibly some extra blanks and special 
characters from the user name, on top of that.

And I for one really do not trust that a Unix temp directory can safely 
have white space in its name without breaking lots of tools' behavior in 
nastily interesting ways.  IIRC it took until Windows 8 for Microsoft to 
finally own up to their error and change it to the profoundly less 
insane "Users".  But by then it was too late, all the damage had been 
done already.


More information about the Cygwin mailing list