-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathlong-example.js
112 lines (109 loc) · 2.18 KB
/
long-example.js
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
var test = require('tape')
var parse = require('../parser')
test('long example', function (t) {
var input = [
"blah >(substituteCommand --with args)",
"first | second",
"echo ${what/hot/not} ok 'singleQuoted arg'\"doubleQuoted $var\" > here",
].join('\n')
t.deepEqual(parse(input), [{
"type": "command",
"command": {
"type": "literal",
"value": "blah"
},
"args": [{
"type": "processSubstitution",
"readWrite": ">",
"commands": [{
"type": "command",
"command": {
"type": "literal",
"value": "substituteCommand"
},
"args": [{
"type": "literal",
"value": "--with"
}, {
"type": "literal",
"value": "args"
}],
"redirects": [],
"env": {},
"control": ";",
"next": null
}]
}],
"redirects": [],
"env": {},
"control": ";",
"next": null
}, {
"type": "command",
"command": {
"type": "literal",
"value": "first"
},
"args": [],
"redirects": [
{
"type": "pipe",
"command": {
"type": "command",
"command": {
"type": "literal",
"value": "second"
},
"args": [],
"redirects": [],
"env": {},
"control": ";",
"next": null
}
}
],
"env": {},
"control": ";",
"next": null
},
{
"type": "command",
"command": {
"type": "literal",
"value": "echo"
},
"args": [{
"type": "variableSubstitution",
"expression": "what/hot/not"
}, {
"type": "literal",
"value": "ok"
}, {
"type": "concatenation",
"pieces": [{
"type": "literal",
"value": "singleQuoted arg"
}, {
"type": "literal",
"value": "doubleQuoted "
}, {
"type": "variable",
"name": "var"
}]
}],
"redirects": [{
"type": "redirectFd",
"fd": 1,
"op": ">",
"filename": {
"type": "literal",
"value": "here"
}
}],
"env": {},
"control": ";",
"next": null
}
])
t.end()
})