OILS / ysh / testdata / array-splice-demo.osh View on Github | oils.pub

23 lines, 14 significant
1
2shopt -s oil-parse-at static-word-eval
3
4shopt -s parse_subexpr_shorthand
5
6myglobal=global
7
8var myarray = :| $myglobal $'line\n' ${z:-default} |
9spec/bin/argv.py @myarray
10echo len=$[len(myarray)]
11echo
12
13append _ '1 2' ${myglobal:-default} (myarray)
14spec/bin/argv.py @myarray
15echo len=$[len(myarray)]
16echo
17
18for item in (myarray) {
19 echo " $item"
20}
21
22# NOTE: This doesn't work for arrays
23#setvar myarray += %(more stuff)