OILS / ysh / testdata / assign.osh View on Github | oilshell.org

67 lines, 27 significant
1echo $'one\ntwo'
2
3# This ignores whitespace. Gah.
4
5#var x = {a: 1}
6
7#setvar x += 1
8
9var a Int = 1 + 2*3
10echo a=$a
11
12var b Float = 5 / 6
13echo b=$b
14
15echo hi
16
17setvar a = b; echo hi
18# not allowed -- has to be Semi or Newline.
19#setvar x = 4 && echo hi
20setvar x = 4
21
22setvar d = 1 # comment
23
24var y =a
25var z=b
26
27echo hi
28
29# Doesn't work yet
30#var myregex = $/ any [c h] /
31#var myarray = %[ foo bar *.[c h] ]
32
33var mycmd = $(echo cmd) + "$(echo cmd)"
34echo mycmd=$mycmd
35
36var mybrace = ${b} + "${b}"
37echo mybrace=$mybrace
38
39# parenthesized
40var paren = (1 + 2) * 3
41echo paren=$paren
42
43# line continuation
44var line_cont = 4 + \
45 5
46echo line_cont=$line_cont
47
48# another way of writing multiline expressions
49var multiline = ( 6 +
50 7)
51echo multiline=$multiline
52
53# Augmented assignment
54var aug = 8
55setvar aug += 9
56echo aug=$aug
57#setvar aug -= 2
58
59#var a[i] = c
60
61# We don't have a type that supports this?
62#setvar a[i, j] = 1
63
64# TODO:
65# - comments
66# - multiline
67