Settings

Theme

Why are there both TMP and TEMP environment variables? (2015)

devblogs.microsoft.com

75 points by ankitg12 5 hours ago · 42 comments

Reader

Semaphor 3 hours ago

> My recollection is that most CP/M programs were configured via patching. At least that’s how I configured them. I remember my WordStar manual coming with details about which bytes to patch to do what. There was also a few dozen bytes of patch space set aside for you to write your own subroutines, in case you needed to add custom support for your printer.

Huh. That is interesting, it was before my time, and I never heard of this :D

  • zabzonk 2 hours ago

    Yes, it was definitely a thing. The patching code had to be in Z80/8080 machine code. I wrote higher performance keyboard and display routines for my copy of Wordstar using this feature.

    • Semaphor 2 hours ago

      Stuff like that is also cool (reminds me a bit of modding some games), patching machine code to improve performance of a compiled app? Very cool! (My dad might have done that, he has an old ZX81)

      But I thought specifically patching something to configure it is such a weird concept that I never would have thought of.

      • matt_kantor an hour ago

        The line between "configuration" and "modding" is pretty thin.

        One could say that the difference is whether the developers intended the changes you're making to be possible or not, but what about programs with dedicated modding APIs?

        • zabzonk an hour ago

          At the time (early to mid 1980s) I think we would say "patching". The Wordstar devs certainly did mean you to do this - the memory locations available were fully documented, and I seem to remember they supplied a small patch utility to incorporate your code into the Wordstar executable.

J8K357R 34 minutes ago

A great example of a decision that likely received little to no thought from an early developer but that has long legs and will stick around forever.

whobre 44 minutes ago

< Rewind to 1973. The operating system common on microcomputers was CP/M

OK. I love Raymond’s blog but this is crazy. Microcomputers existed only as a prototype in 1973 (things like Intel’s Intellec dev systems) and there were no operating systems for them. Strictly speaking, Kildall did start developing CP/M in 1973, but at that point it ran only on a simulator on a PDP-10 mainframe.

1979, sure. 1973? Way too early…

xg15 3 hours ago

I didn't know it was such a chaos.

So I guess the moral of the story is: Ensure they always point to the same path, or else...

QuantumNomad_ 2 hours ago

> My recollection is that most CP/M programs were configured via patching.

I honestly would have liked that better for a lot of programs than the dotfiles they litter all over my home directory.

  • fredoralive 2 hours ago

    Part of the philosophy of the slightly odd suckless people is their projects are mostly configured by changing the source code and recompiling. This is I suppose a similar approach in a modern open source vein. Although their general asceticism makes their projects a bit of an acquired taste I suspect.

    • analog_daddy 2 hours ago

      Ohh acquired taste it is.. I had two stints with suckless software. First, when i was in early twenties when I had a lot of time in the world, and thought the manliest way to talk to a machine is all through low level C code. Had a whole flow to patch it and heck the code is so well written and commented, i was able to understand it. Then, i guess life happened and i discovered more interesting stuff to spend time on.

      And now in my late twenties, suckless terminal is the only one that would work reliably on a shitty old enterprise linux system at work. Yeah, we got xterm and konsole (the older one). I am seeing them in a whole different light now. I did not read the source code now and it is effectively a foreign language to me, but just being able to have modern features in it without too many dependencies is a different level of bliss. This time, I am glad I have the flexi patch to the rescue since, i passed on suckless terminal as a real alternative since I don’t want to patch it manually or solve merge conflicts!

      Even though I don’t like the elitist attitude of the project, can’t deny they got a point. Why does a terminal emulator need to be so complicated!

      https://github.com/bakkeby/st-flexipatch

      • archargelod 30 minutes ago

        > I don’t want to patch it manually or solve merge conflicts

        I wonder, is this really such a big problem? How often do people add patches or change their config?

        I've configured my st once and haven't touched that build for years. I use only few patches like scrollback, custom colortheme and a "plumb" for few scripts.

        I've also had an opportunity recently, to try a "modern" and trendy terminal and I can't see myself switching to something slower (in terms of lag) and using 10x more memory and cpu even when idle for literally zero gain.

  • Hendrikto an hour ago

    If people just followed the XDG Base Directory Specification, config file littering would be a non-issue. More and more projects adopt it, even holdouts like Firefox.

    • ninkendo 26 minutes ago

      I wonder how many apps actually read the correct XDG environment variables and obey them, versus just hardcoding paths that match their machine’s config paths (typically ~/.config/*)

      I almost want to set up a VM that sets up XDG_CONFIG_HOME as ~/.foobar and see how many apps actually respect it, and how many still write to ~/.config.

      • jdpage 4 minutes ago

        A few years ago I had a Windows box where I pointed XDG_CONFIG_HOME et al to the corresponding-ish Windows paths (AppData subdirectories, mostly) so that the many Linux-derived CLI programs I was using wouldn't clutter up my userdir, and it worked pretty well, though there were a few programs that didn't get the memo. Unfortunately I don't remember which ones they were. Most programs get it right, though!

    • skydhash 6 minutes ago

      I don’t mind ~/.* for config, especially when the config is just one or two files. What I don’t like is programs like go and cargo treating my $HOME as a dumping ground for every file they want to download and/or cache.

    • user3939382 an hour ago

      I contemplated for years and eventually saw someone implement a transparent kernel redirect for programs reaching for ~/.*

  • PunchyHamster 2 hours ago

    Well, they are supposed to be all in .config, problem is many app developers think they are special little boys that deserve its own directory

    • delta_p_delta_x an hour ago

      %LOCALAPPDATA% on Windows. Or better still, use GetAppContainerFolderPath or SHGetKnownFolderPath with FOLDERID_LocalAppData.

      • ziml77 36 minutes ago

        I don't know if anyone is actually using roaming profiles, but config should go into the %APPDATA% folder to support that. %LOCALAPPDATA% is for things that shouldn't be synced to different machines, such as caches.

        • Uvix 13 minutes ago

          I know we used to use them in our corporate environment. Not sure if we still do, or if they gave up and called OneDrive “good enough”.

    • delusional an hour ago

      It all sounds so easy, until you learn about the XDG Base Directory Specification[1]. You're actually supposed to do a whole song and dance around a hierarchical set of environment variables, associated defaults, and resolution orders.

      Interfacing with people is never easy.

      [1]: https://specifications.freedesktop.org/basedir/latest/

      • archargelod 5 minutes ago

        No. Actually, it's easy. Just check for directory or use a fallback. For example here's how you'd do this in bash:

            export CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}"
            export CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}"
            ...
        
        XDG_*_DIRS are a bit more complicated, but nothing that can't be solved with a simple for-loop in any modern programming language.
  • ozlikethewizard 2 hours ago

    Yea this is something I'd love to see standardised, a distro that was able to enforce a .config folder somehow would be a winner for me. Think weve probably missed the boat though.

    • 9dev 2 hours ago

      As these things go, there obviously is a standard for this called the XDG Base Directory Specification[0], which elegantly solves almost all configuration path needs—and has been ignored, violated, or only partially implemented, since forever.

      [0]: https://specifications.freedesktop.org/basedir/latest/

      • amelius an hour ago

        Say what you want about AI but one nice aspect of it is that it is more likely to follow these kinds of standards than humans.

  • mort96 2 hours ago

    You would've preferred binary patching of the executable? Really?

fooqux an hour ago

I'm confused by the CP/M reference. Author says it'll be important later then proceeds to explain how it had nothing to do with CP/M or the 8080 CPU.

  • driggs 3 minutes ago

    Agree, CP/M has nothing to do with the story, nor does the 8080/8086 sidetrack.

    The whole story is that Microsoft just never bothered to standardize, despite using it themselves.

  • zabzonk 40 minutes ago

    could you quote the text you are referring to?

    • fooqux 37 minutes ago

      "Rewind to 1973. The operating system common on microcomputers was CP/M. The CP/M operating system had no environment variables. That sounds like a strange place to start a discussion of environment variables, but it’s actually important."

      • flohofwoe 25 minutes ago

        Just a few lines below:

        "Over time, programs were written with MS-DOS as their primary target, and they started to realize that they could use environment variables as a way to store configuration data. In the ensuing chaos of the marketplace, two environment variables emerged as the front-runners for specifying where temporary files should go: TEMP and TMP."

        And before that there are a few paragraphs describing the migration of applications from i8080/Z80 based CP/M towards x86 based DOS via mechanical translation.

        • rendaw 10 minutes ago

          I was curious seeing this thread, and I just looked and don't get it either. AFAICT the CP/M references could have been entirely omitted and nothing in the narrative about TMP and TEMP would change.

Jedd 3 hours ago

1995-ish. Telstra (Australia Telecom). Probably about 50k desktop computers across the organisation. One day a small file turned up in everyone's network home directory called null. A *nix person had evidently had a go at writing a .bat file.

Why do we need to adopt extant standards? (I was going to ask, why standardise? But realised that might confound the North Americans. : )

  • lelanthran 3 hours ago

    >One day a small file turned up in everyone's network home directory called null. A *nix person had evidently had a go at writing a .bat file

    I assume that they first tried /dev/null which failed, so then moved onto just plain null?

    Otherwise it would not make sense that a unix programmer did this. More likely ula dos programmer misspelled NUL as null.

    • rep_lodsb an hour ago

      Fun fact: "/dev/nul" (with only one L) would have worked, even if there is no directory with that name.

      That's been a feature since DOS 2.0, there was even an undocumented option AVAILDEV to make the prefix mandatory, instead of having device names present everywhere. But it broke the common trick used to detect if a directory exists ("if exist c:\some\path\nul").

    • 3form 2 hours ago

      Unix programmer remembered that in there's no /dev/null in DOS and that it's something shorter, and tried null which worked. Didn't check the directory contents afterwards. So basically your first sentence - doesn't seem at all unlikely to me. (I mean, I think it happened to me at least once too)

    • jtoledo 2 hours ago

      I've already created a 'NULL' file, but it was not a Unix thing... It was just because I got confused if it was NULL as in the programming languages I usually use.

  • cachius 2 hours ago

    What text was in there that he tried to discard?

NSPG911 2 hours ago

always shove it to `%LOCALAPPDATA%/Temp`, or `~/AppData/Local/Temp`, and don't think otherwise

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection