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

53 lines, 15 significant
1
2echo 'This is a shell script with OSH extensions!'
3echo
4
5var x = 1 + 2*3
6
7echo "x: $x"
8
9# NOTE: we will take over 'set'
10setvar x += 1
11
12echo "x: $x"
13
14var mylist = [1, 2, 3]
15
16var y = mylist[1] * 10
17
18echo "y: $y"
19
20var list2 = mylist ++ [4, 5]
21
22# TODO: $json(list) should print [1,2,3,4,5]?
23#echo $list2
24
25# This is a more explicit representation.
26pp cell list2
27
28str1='shell string' # traditinoal shell-style assignment
29
30# Oil assignment
31var str2 = "Oil string"
32
33var str3 = str1 ++ str2
34
35echo "str3 = $str3"
36
37
38
39#var f1 = 1.23
40#var f2 = 3.45
41
42
43
44# TODO:
45# - lexing
46# - single-quoted strings
47# - floats
48# - parsing
49# - dicts
50# - comments at end of line
51# - eval
52# - Mutate variables with 'setvar'
53