Why Sponsor Oils? | source | all docs for version 0.23.0 | all versions | oilshell.org
Oils Reference — Chapter Special Variables
This chapter describes special variables for OSH and YSH.
(in progress)
Replacement for "$@"
TODO
The directory the current script resides in. This knows about 3 situations:
oshrc
in an interactive shellosh myscript.sh
source
builtinIt's useful for "relative imports".
_status
DEPRECATED: Use _error.code
instead.
_error
A Dict
that's set by the try
builtin.
The integer _error.code
is always present:
try {
ls /tmp
}
echo "status is $[_error.code]"
Some errors also have a message
field, like JSON/J8 encoding/decoding errors,
and user errors from the error builtin.
try {
echo $[toJson( /d+/ )] # invalid Eggex type
}
echo "failed: $[_error.message]" # => failed: Can't serialize ...
_pipeline_status
After a pipeline of processes is executed, this array contains the exit code of each process.
Each exit code is an Int. Compare with
PIPESTATUS
.
_process_sub_status
The exit status of all the process subs in the last command.
YSH read
sets this variable:
read --all < myfile
echo $_reply
OILS_VERSION
The version of Oils that's being run, e.g. 0.23.0
.
LIB_OSH
The string ///osh
, which you can use with the source builtin.
source $LIB_OSH/two.sh
LIB_YSH
The string ///ysh
, which you can use with the source builtin.
source $LIB_YSH/yblocks.ysh
OILS_GC_THRESHOLD
At a GC point, if there are more than this number of live objects, collect garbage.
OILS_GC_ON_EXIT
Set OILS_GC_ON_EXIT=1
to explicitly collect and free()
before the process
exits. By default, we let the OS clean up.
Useful for ASAN testing.
OILS_GC_STATS
When the shell process exists, print GC stats to stderr.
OILS_GC_STATS_FD
When the shell process exists, print GC stats to this file descriptor.
The float value for "not a number".
(The name is consistent with the C language.)
The float value for "infinity". You can negate it to get "negative infinity".
(The name is consistent with the C language.)
Used for word splitting. And the builtin shSplit()
function.
TODO: bash compat
TODO: bash compat
bash compat: serialized options for the set
builtin.
bash compat: serialized options for the shopt
builtin.
$HOME is used for:
Note: The shell doesn't set $HOME. According to POSIX, the program that invokes the login shell sets it based on /etc/passwd.
A colon-separated string that's used to find executables to run.
Result of regex evaluation [[ $x =~ $pat ]]
.
After a pipeline of processes is executed, this array contains the exit code of each process.
Each exit code is a Str. Compare with
_pipeline_status
.
The name of the "host" or machine that Oils is running on, determined by
gethostname()
.
The operating system that Oils is running on, determined by uname()
.
Examples: linux darwin ...
TODO
TODO
An array of words, split by : and = for compatibility with bash. New completion scripts should use COMP_ARGV instead.
Discouraged; for compatibility with bash.
Discouraged; for compatibility with bash.
Discouraged; for compatibility with bash.
Discouraged; for compatibility with bash.
User-defined completion functions should Fill this array with candidates. It is cleared on every completion request.
An array of partial command arguments to complete. Preferred over COMP_WORDS. The compadjust builtin uses this variable.
(An OSH extension to bash.)
Override the default OSH history location.
Override the default YSH history location.
OSH read sets this:
read < myfile
bash compat
bash compat