| 1 | ---
|
| 2 | title: OSH Assignment (Oils Reference)
|
| 3 | all_docs_url: ..
|
| 4 | body_css_class: width40
|
| 5 | default_highlighter: oils-sh
|
| 6 | preserve_anchor_case: yes
|
| 7 | ---
|
| 8 |
|
| 9 | <div class="doc-ref-header">
|
| 10 |
|
| 11 | [Oils Reference](index.html) —
|
| 12 | Chapter **OSH Assignment**
|
| 13 |
|
| 14 | </div>
|
| 15 |
|
| 16 | This 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 |
|
| 33 | Array 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 |
|
| 40 | Their type is [BashArray][].
|
| 41 |
|
| 42 | In 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 |
|
| 52 | Associative arrays map strings to strings:
|
| 53 |
|
| 54 | declare -A assoc=(['k']=v ['k2']=v2)
|
| 55 |
|
| 56 | Their type is [BashAssoc][].
|
| 57 |
|
| 58 | In 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 |
|
| 81 | Another name for the [declare](#declare) builtin.
|