aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/build/script/parser+pipe-expr.test.testscript
blob: 3dd6b1b2512de75d9ff7a2681b5430366597b834 (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
# file      : libbuild2/build/script/parser+pipe-expr.test.testscript
# license   : MIT; see accompanying LICENSE file

: pipe
:
$* <<EOI >>EOO
cmd1 | cmd2|cmd3
EOI
cmd1 | cmd2 | cmd3
EOO

: log
:
$* <<EOI >>EOO
cmd1 || cmd2&&cmd3
EOI
cmd1 || cmd2 && cmd3
EOO

: pipe-log
:
$* <<EOI >>EOO
cmd1 | cmd2 && cmd3 | cmd4
EOI
cmd1 | cmd2 && cmd3 | cmd4
EOO

: exit
:
$* <<EOI >>EOO
cmd1|cmd2==1&&cmd3!=0|cmd4
EOI
cmd1 | cmd2 == 1 && cmd3 != 0 | cmd4
EOO

: here-doc
:
$* <<EOI >>EOO
cmd1 <<EOI1 | cmd2 >>EOO2 && cmd3 <<EOI3 2>&1 | cmd4 2>>EOE4 >>EOO4
input
one
EOI1
ouput
two
EOO2
input
three
EOI3
error
four
EOE4
output
four
EOO4
EOI
cmd1 <<EOI1 | cmd2 >>EOO2 && cmd3 <<EOI3 2>&1 | cmd4 >>EOO4 2>>EOE4
input
one
EOI1
ouput
two
EOO2
input
three
EOI3
output
four
EOO4
error
four
EOE4
EOO

: leading
:
$* <<EOI 2>>EOE != 0
| cmd
EOI
buildfile:11:1: error: missing program
EOE

: trailing
:
$* <<EOI 2>>EOE != 0
cmd &&
EOI
buildfile:11:7: error: missing program
EOE

: redirected
:
{
  : input
  :
  {
    : first
    :
    $* <<EOI >>EOO
    cmd1 <foo | cmd2
    EOI
    cmd1 <foo | cmd2
    EOO

    : non-first
    :
    $* <<EOI 2>>EOE != 0
    cmd1 | cmd2 <foo
    EOI
    buildfile:11:13: error: stdin is both piped and redirected
    EOE
  }

  : output
  :
  {
    : last
    :
    $* <<EOI >>EOO
    cmd1 | cmd2 >foo
    EOI
    cmd1 | cmd2 >foo
    EOO

    : non-last
    :
    $* <<EOI 2>>EOE != 0
    cmd1 >foo | cmd2
    EOI
    buildfile:11:11: error: stdout is both redirected and piped
    EOE
  }
}