Is there a common way in which environment variables are accessed, stored, or used by the kernel?
There are built-in functions for querying and setting vars in the system environment, but there are also instances where environment variables seem to be mirrored by strings or list of strings stored in symbols, often prefixed by $:
$BaseDirectory
(related to MATHEMATICA_BASE environment variable)
$UserBaseDirectory
(related to MATHEMATICA_USERBASE environment variable)
In addition, the system sessions docs mention:
MATHKERNELINIT
--> specifies command‐line options for the Wolfram Language kernel
MATHINIT
--> specifies command‐line options for the Wolfram System front end
--- (edited to avoid misinformation) ---
@Szabolcs points out that
$Path
is not related to PATH, and others listed below do not generally correspond to OS environment variables:
$OperatingSystem
, $System
, $SystemID
$HomeDirectory
, $InitialDirectory
$TemporaryDirectory
, $TemporaryPrefix
A comment by @rhermans on this question piqued my interest in how these kinds of symbols are used when they seem to represent environment variables.
$TemporaryDirectory gives the main system directory for temporary files on your computer system. It's reporting a system variable, not defining where it should be.
Is it common to use a $var for "reporting the state" of an environment variable?
$TempDirectory
to your liking. $\endgroup$$Path
has an entirely different purpose and should not be confused with the system'sPATH
environment variable. $\endgroup$