You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[osh] Implement InitializerList, e.g. a=(v [k]=v [k]+=v) (#2279)
* [osh/word_parse] Introduce InitializerLiteral for `(v [k]=v [k]+=v ...)`
* [osh/word_parse] Allow mixed forms of initializer in BashAssocLiteral
We allow mixed forms of initializer such as (1 2 [3]=4). We extend
the element type of "BashAssocLiteral.pairs" to "InitializerWord",
which is either "ArrayWord" or "AssocPair". "ArrayWord" is the non
array-assignment form of a word. In addition, "AssocPair" now
records also whether the word in initializer has the form "[]=" or
"[]+=".
* [refactor frontend/syntax] Rename "{BashAssoc => Initializer}Literal"
* [osh/cmd_eval] Process InitializerList for tempenv
* [core/bash_impl] Implement InitializerList_ToStrForShellPrint for xtrace
* [refactor frontend/id_kind_def] Rename "Id.Right_{ShArrayLiteral => Initializer}"
* [osh] Add temporary adjustment for "assoc=(1 2)"
The current OSH behavior of overwriting "assoc" with a new indexed
array for "assoc=(1 2)" conflicts with the Bash 5.1 feature
"assoc=(key value)". The current master behavior will soon be changed
when the Bash 5.1 feature is implemented, yet we keep the current
master behavior for now to avoid changing the behavior too many times.
This commit adjusts the behavior to be backward compatible with the
current master version.
* [spec] Update spec tests for "arr=([index]=value)"
* [spec/assoc] Update spec tests for "assoc=([key]=value)"
We now support the sparse-array initialization of the form
"arr=([index]=value)", so an attempt of assigning an initializer
list to an indexed array no longer overwrites the original array
with BashAssoc. With this change, the expected behaviors of three
spec tests in spec/assoc.test.sh are changed. We adjust the
expected results of the three tests and copy them into
spec/ble-sparse.test.sh. We also leave BashAssoc versions of spec
tests in spec/assoc.test.sh.
* [spec/ysh-printing] Update spec tests for "assoc=([key]=value)"
* [spec/assign-extended] Confirm that "declare -p sp" is correctly parsed
The initialier-list implementation resolves the inconsistency in the
sparse array representation of the form "declare -a sp=([2]=v)". This
commit removes the "oils_failures_allowed" introduced in Ref. [1] (as
a part of PR 2257, which turned on the sparse array representation of
indexed arrays).
[1] bfa7497#diff-097d35f191fa3ada9a05d61d3020a2b3acb43e800141b67021094fb05d8e769e
* [spec/assoc] Reduce "oils_failures_allowed"
OSH now implements the feature required by spec/assoc#37 "Implicit
increment of keys" so passes the test.
* [doc] Update reference
* [doc/{ref/{chap-type-method,toc-osh},known-differences,quirks}] Update
* [refactor] Rename "{Sh => Ysh}ArrayLiteral"
0 commit comments