OSH Quirks

This document describes corner cases in OSH for compatibility.

Related: Known Differences.

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

For Bash Compatibility

The meaning of () on the RHS

In Oils, 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

Related


Generated on Sun, 04 Feb 2024 00:32:22 -0500