blob: 0c16cd84b0dd71dbecad35ebc46e392d6398f52f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
# Implementation of *Ēostre’s Shell*
# Syntax
## Piping
```esh
program_0 | program_1 | program_2 | ... | program_n
```
## Comments
```esh
# Comments are written like this
```
## Forcing Pipe Mode
### Force String
```esh
mode(string) { program_0 | program_1 } | program_2 | program_3
```
### Force *EAPM*
```esh
unsafe {
mode(raw) { program_0 | program_1 } | program_2 | program_3
}
```
Forcing `EAPM` can only happen in a unsafe block.
All pipes in a forced mode scope will be forced to this mode.
In this example `program_0` and `program_1` will run in the forced
mode.
## If-Statement
```esh
if (program arg_1 arg_2 ... arg_n) {
# do something here
}
```
```esh
if (program arg_1 arg_2 ... arg_n) {
# do something here
} else {
# do something else
}
```
```esh
if (program0 arg_1 arg_2 ... arg_n) {
# do something here
} else if program1 arg_1 arg_2 ... arg_n {
# do something here
} else {
# do something else
}
```
## For-Loop
For loops are always *line-based*
```esh
for line in (program arg_1 arg_2 ... arg_n) {
# do something here
}
```
## While-Loop
```esh
while (program arg_1 arg_2 ... arg_n) {
# do something here
}
```
## Variables
### Set
```esh
var = {
program arg_1 arg_2 ... arg_n
}
```
### Get
This will pass `var` as `arg_1`
``` esh
program arg_1 (var) arg_3 ... arg_n
```
## String
### Normal String
``` esh
var = "Some random string"
```
#### Embedding other variables and program calls into string definition.
``` esh
var2 = "this is var: (var) and program gives the output: {program arg_1 arg_2 ... arg_n}"
```
If you want to use `{` or `}` as a real character use the escape character `\` or use a raw
string:
``` esh
var = "The following is a curly bracket: \{"
```
### Raw String
A raw string is a string where no character except the end character
is treated special
``` esh
var = 'Some string where I can use " without ending the string'
```
## Functions
``` esh
fn my-function(arg_1 arg_2 arg_3) {
# do something here
}
```
### `Use`-Keyword
The `use` keyword passes a variable from the parent to the child scope.
If the variable does not exist in the parent context yet it will
set it to a empty string.
``` esh
fn my-function(arg_1 arg_2 arg_3) use (var0 var1) {
# do something here
}
```
## Multi-Line Expressions
``` esh
program arg_1 \
arg_2 \
...
arg_n
```
## Merging Lines
``` esh
program0 arg_1 arg_2 ... arg_n; program1 arg_1 arg_2 ... arg_n
```
``` esh
program0 && program1
```
``` esh
program0 || program1
```
|