Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.

Special Variables

This chapter in the Oils Reference describes special variables for OSH and YSH.

Table of Contents
Shell Vars
ARGV
_DIALECT
_this_dir
Platform
OIL_VERSION
Exit Status
_status
_pipeline_status
_process_sub_status
Tracing
SHX_indent
SHX_punct
SHX_pid_str
Environment Variables
Shell Options
Other Env
Oil Paths
Special Variables
Special
POSIX Special
Other Special
Oil Special
Platform
Call Stack
Tracing
Process State
Process Stack
Shell State
Completion
Functions
Other Special

Shell Vars

ARGV

Replacement for "$@"

_DIALECT

Name of a dialect being evaluated.

_this_dir

The directory the current script resides in. This knows about 3 situations:

It's useful for "relative imports".

Platform

OIL_VERSION

The version of Oil that is being run, e.g. 0.9.0.

Exit Status

_status

Set by the try builtin.

try ls /bad
if (_status !== 0) {
  echo 'failed'
}

_pipeline_status

Alias for PIPESTATUS.

_process_sub_status

The exit status of all the process subs in the last command.

Tracing

SHX_indent

SHX_punct

SHX_pid_str

Environment Variables

Shell Options

SHELLOPTS

For the 'set' builtin.

BASHOPTS

For the 'shopt' builtin.

Other Env

HOME

$HOME is used for:

  1. ~ expansion
  2. ~ abbreviation in the UI (the dirs builtin, \W in $PS1).

Note: The shell doesn't set $HOME. According to POSIX, the program that invokes the login shell sets it based on /etc/passwd.

PATH

A colon-separated string that's used to find executables to run.

IFS

Used for word splitting. And the builtin split() function.

Oil Paths

Special Variables

Special

POSIX Special

Other Special

Oil Special

Platform

Call Stack

Tracing

Process State

Process Stack

Shell State

Completion

COMP_WORDS

An array of words, split by : and = for compatibility with bash. New completion scripts should use COMP_ARGV instead.

COMP_CWORD

Discouraged; for compatibility with bash.

COMP_LINE

Discouraged; for compatibility with bash.

COMP_POINT

Discouraged; for compatibility with bash.

COMPREPLY

User-defined completion functions should Fill this array with candidates. It is cleared on every completion request.

COMP_ARGV

An array of partial command arguments to complete. Preferred over COMP_WORDS. The compadjust builtin uses this variable.

(An OSH extension to bash.)

Functions

Other Special


Generated on Wed, 06 Dec 2023 01:04:01 -0500