Definitions
Environment
State of your computer from which commands are executed.
- consists of the name of your current directory, your current user, its permissions, the variables accessible to it and the commands it can run at the moment.
Environment variable
A variable that can be read by executables and CJTaskrunner.
- Set in your shell before CJTaskrunner runs, or
- Set using the
@envdirective. - Globally available within a taskfile execution context.
Runtime variable
A variable whose value can be read only by CJTaskrunner inside of a task.
- Set in a task using the
@setdirective. - Accessible only in CJTaskrunner.
- Lasts the duration of the task context and is passed to subordinate tasks as a snapshot.
- Will override other variables with the same name for the duration of the task. Most recent definition wins.
- Can be promoted to an exported variable.
Exported variable
A variable that has the same properties of an environment variable but originated as a runtime variable.
- A runtime variable that is used in an
@exportdirective. - As a shortcut can be defined directly in the
@exportdirective. - Exported values are shared across the taskfile execution context. A task can still shadow the same name with
@setinside its own task context, or overwrite the shared value with another@export.
Task context
The environment that spans the execution of a single task.
- This is the narrowest and most isolated context.
- It starts as a copy of the taskfile execution context from which the task is run.
- A copy of it is propagated to subordinate task runs using
@taskand@await. - Unexported variable changes are discarded when the task ends, as well as working directory changes.
Taskfile execution context
the environment that exists from the moment you run a CJTaskrunner task until it finishes.
- Starting as a snapshot of your shell environment, it holds any environment variable references and exported variables and makes them available to task contexts.
- Ultimately, all environment changes made in a taskfile execution context are discarded after CJTaskrunner completes its run.
Variable
A named container holding a value.
- You refer to a variable by its name, such as MR_VAR.
- Variables are further divided into runtime variables, environment variables, and exported variables.
- The name must consist of ascii letters, digits or an underscore. It cannot start with a digit.
- If you put a
$in front of the variable name, CJTaskrunner will exchange the whole thing for the variable’s value. This is what is called “interpolating” or “dereferencing”.