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

Quirks

This document describes corner cases in Oil for compatibility.

Related: Known Differences.

Table of Contents
For Bash Compatibility
The meaning of () on the RHS

For Bash Compatibility

The meaning of () on the RHS

In Oil, values are tagged with types like Str and AssocArray, as opposed to the locations of values (cells).

This statement binds an empty indexed array to the name x:

x=()  # indexed by integers

Quirk: When it's clear from the context, () means an empty associative array:

declare -A x=()  # indexed by strings, because of -A

This only applies when the array is empty. Otherwise the type is determined by the literal:

declare x=(one two)  # indexed array
declare x=(['k']=v)  # associative array

Redundant but OK:

declare -a x=(one two)  # indexed array
declare -A x=(['k']=v)  # associative array

Errors:

declare -A x=(one two)  # inconsistent
declare -a x=(['k']=v)  # inconsistent

Generated on Thu Sep 3 10:28:33 PDT 2020