Why Sponsor Oils? | source | all docs for version 0.23.0 | all versions | oilshell.org
This document describes corner cases in OSH.
Related: Known Differences.
() on the RHSIn 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
First, some background. These two shell features are fundamentally incompatible:
shopt -s lastpipe semantics: the last part of a pipeline can (sometimes) be
run in the current shell.
As evidence of this incompatibility, note that:
shopt -s lastpipe setting in job control
shellsNow that we have that background, note that there's is a third feature that
interacts: the DEBUG trap.
OSH emulates the bash DEBUG trap, which runs before "leaf"
commands like echo hi, a=b, etc.
If we run this trap before the last part of a pipeline, and that part is
run in the current shell (lastpipe), then the DEBUG trap makes an existing
race condition worse.
For example, in
echo hi | cat
there's nothing stopping echo hi from finishing before cat is even started,
which means that cat can't join the process group of the leader.
So we simply disable the DEBUG trap for the last part of the pipeline, but
only when job control is enabled. This won't affect debugging batch
programs.
Related issues in other shells: