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 GetTempFileName 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 GetTempFileName 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."
Source: Hacker News · Summarized by HeadlinesBriefing