3 ms·
> Many programs tried to appease both sides of the conflict by checking for both, and it was up to the mood of the original author which one it checked first. F
by dalke 12y ago
> Many programs tried to appease both sides of the conflict by checking for both, and it was up to the mood of the original author which one it checked first. For example, the old DISKCOPY and EDIT programs would look for TEMP before looking for TMP.
> Windows went through a similar exercise, but for whatever reason, the original authors of the GetTempFileName function chose to look for TMP before looking for TEMP.
For what it's worth, Python, which also supports Unix-like systems, checks for 'TMPDIR', 'TEMP', and then 'TMP'.
- JoshTriplett 12y ago> For what it's worth, Python, which also supports Unix-like systems, checks for 'TMPDIR', 'TEMP', and then 'TMP'. Python checks TEMP and TMP for Windows compatibility; Linux programs standardized on TMPDIR (to the extent they don't incorrectly hardcode /tmp).
- dalke 12y agoWhat's a bit unusual about Python is that it tries all three environment variables on every OS. I would have expected that it would only try TMPDIR on Unix-like machines, and TMP/TEMP on Windows-based machines. There's no compatibility expectation that Windows environment variables would work on Unix-like OSes, or vice versa. FWIW, TMPDIR was part of standard Unix practices before Torvalds wrote the first line of the Linux kernel. For example, 4.3BSD-Reno came out 1990 . If you grab the tape from http://sourceforge.net/projects/bsd42/files/Install%20tapes/4.3%20BSD%20RENO/ http://sourceforge.net/projects/bsd42/files/Install%20tapes/... and page through it you'll see the man pages were "Printed 7/27/90" and contain things like: If the environment variable TMPDIR is set, the string denoted by TMPDIR will be used as the name of the directory where the temporary files are created. -- yacc(1) The environmental variable ``TMPDIR'' (if set), the argument dir (if non-NULL), the directory ``/usr/tmp'' and the direc- tory ``/tmp'' are tried, in the listed order, as directories in which to store the temporary file. -- TMPFILE(3) Python comes out of the Unix heritage (van Rossum contributed the glob() routine to BSD Unix in 1986), which is likely why the first commit of tempfile.py, Nov. 12 1991, mentions TMPDIR, though it didn't actually support the environment variable until Jan 14 1992. OTOH, it didn't gain TMP/TEMP support until Aug 12 1997. Even then, the file says at the top: # XXX This tries to be not UNIX specific, but I don't know beans about # how to choose a temp directory or filename on MS-DOS or other # systems so it may have to be changed...