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

Variable Scope in Shell and Oil

NOTE: Most important content has been moved to the variables doc.

This doc has details for advanced users.

Table of Contents
Details
Three Semantics for Cell Lookup
scope_e.Dynamic
scope_e.LocalOrGlobal
scope_e.LocalOnly
Where Are These Semantics Used?
LocalOrGlobal For Reading Variables, and for setvar
Related Links

Details

Three Semantics for Cell Lookup

Cells are locations for variables.

Named after enums.

scope_e.Dynamic

What shell uses

scope_e.LocalOrGlobal

In Oil, it does one of three things:

  1. mutates an existing local
  2. mutates an existing global
  3. create a new global

In shell, it does these things:

  1. Mutate any variable of th e name up the stack.

scope_e.LocalOnly

For loop variables, etc. Mutates exactly one scope!

Where Are These Semantics Used?

LocalOrGlobal For Reading Variables, and for setvar

Constructs That Retrieve Cells:

The other ones deal with values. These deal with cells.

Related Links


Generated on Thu Dec 29 21:10:40 EST 2022