OILS / ysh / testdata / array-splice-demo.osh View on Github | oilshell.org

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