HeadlinesBriefing favicon HeadlinesBriefing.com

The Strange Tale of TMP vs TEMP: A Windows History Lesson

Hacker News •
×

If you've ever peeked at your system environment variables, you noticed two that both claim to specify temporary file locations: TMP and TEMP. Why both? The answer lies in a decades-long conflict stretching back to 1981 and MS-DOS.

MS-DOS arrived as a successor to CP/M, which had no environment variables at all - programs required patching executables to configure temp file locations. When MS-DOS added environment variables, no existing programs used them since they were all ported from CP/M. Two competing standards emerged: TEMP and TMP. MS-DOS 2.0 introduced piping, which needed temp files, and the authors chose TEMP.

Windows took a different path - the original Get­Temp­File­Name function checked TMP first. Many programs tried toappease both sides by checking for both, but the order depended entirely on the original author's preference. DISKCOPY and EDIT checked TEMP before TMP, while Windows APIs do the reverse.

The practical upshot: Windows programs using Get­Temp­File­Name will prefer TMP, making it the more reliable choice on modern systems. Both variables still appear in the Environment Variables dialog, duking it out like "Adidas versus Puma, geek version."