OILS / doc / ref / chap-osh-assign.md View on Github | oilshell.org

81 lines, 46 significant
1---
2title: OSH Assignment (Oils Reference)
3all_docs_url: ..
4body_css_class: width40
5default_highlighter: oils-sh
6preserve_anchor_case: yes
7---
8
9<div class="doc-ref-header">
10
11[Oils Reference](index.html) &mdash;
12Chapter **OSH Assignment**
13
14</div>
15
16This chapter describes OSH assignment, which looks like `x=value`.
17
18<span class="in-progress">(in progress)</span>
19
20<div id="dense-toc">
21</div>
22
23## Operators
24
25### sh-assign
26
27### sh-append
28
29## Compound Data
30
31### sh-array
32
33Array literals in shell accept any sequence of words, just like a command does:
34
35 ls $mystr "$@" *.py
36
37 # Put it in an array
38 a=(ls $mystr "$@" *.py)
39
40Their type is [BashArray][].
41
42In YSH, use a [list-literal][] to create a [List][] instance.
43
44[BashArray]: chap-type-method.html#BashArray
45
46[List]: chap-type-method.html#List
47[list-literal]: chap-expr-lang.html#list-literal
48
49
50### sh-assoc
51
52Associative arrays map strings to strings:
53
54 declare -A assoc=(['k']=v ['k2']=v2)
55
56Their type is [BashAssoc][].
57
58In YSH, use a [dict-literal][] to create a [Dict][] instance.
59
60[BashAssoc]: chap-type-method.html#BashAssoc
61
62[Dict]: chap-type-method.html#Dict
63[dict-literal]: chap-expr-lang.html#dict-literal
64
65## Builtins
66
67### local
68
69### readonly
70
71### export
72
73### unset
74
75### shift
76
77### declare
78
79### typeset
80
81Another name for the [declare](#declare) builtin.