You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also note that `complete` is special, it doesn't work with `e>|`, `o+e>|`.
84
+
85
+
## Stdio and redirection behavior examples
86
+
87
+
Pipeline and redirection behavior can be hard to follow when they are used with subexpressions, or custom commands. Here are some examples that show intended stdio behavior.
88
+
89
+
### Examples for subexpression
90
+
91
+
- (^cmd1 | ^cmd2; ^cmd3 | ^cmd4)
92
+
93
+
| Command | Stdout | Stderr |
94
+
| ------- | -------- | ---------- |
95
+
| cmd1 | Piped | Terminal |
96
+
| cmd2 |*Terminal*| Terminal |
97
+
| cmd3 | Piped | Terminal |
98
+
| cmd4 | Terminal | Terminal |
99
+
100
+
- (^cmd1 | ^cmd2; ^cmd3 | ^cmd4) | ^cmd5
101
+
102
+
It runs `(^cmd1 | ^cmd2; ^cmd3 | ^cmd4)` first, then pipes *stdout* to `^cmd5`, where both stdout and stderr are directed to the Terminal.
103
+
104
+
| Command | Stdout | Stderr |
105
+
| ------- | -------- | ---------- |
106
+
| cmd1 | Piped | Terminal |
107
+
| cmd2 |*Terminal*| Terminal |
108
+
| cmd3 | Piped | Terminal |
109
+
| cmd4 | Piped | Terminal |
110
+
111
+
- (^cmd1 | ^cmd2; ^cmd3 | ^cmd4) e>| ^cmd5
112
+
113
+
It runs `(^cmd1 | ^cmd2; ^cmd3 | ^cmd4)` first, then pipes *stderr* to `^cmd5`, where both stdout and stderr are directed to the Terminal.
114
+
115
+
| Command | Stdout | Stderr |
116
+
| ------- | -------- | -------- |
117
+
| cmd1 | Piped | Terminal |
118
+
| cmd2 | Terminal | Terminal |
119
+
| cmd3 | Piped | Terminal |
120
+
| cmd4 | Terminal | Piped |
121
+
122
+
- (^cmd1 | ^cmd2; ^cmd3 | ^cmd4) o+e>| ^cmd5
123
+
124
+
It runs `(^cmd1 | ^cmd2; ^cmd3 | ^cmd4)` first, then pipes *stdout and stderr* to `^cmd5`, where both stdout and stderr are directed to the Terminal.
125
+
126
+
| Command | Stdout | Stderr |
127
+
| ------- | -------- | -------- |
128
+
| cmd1 | Piped | Terminal |
129
+
| cmd2 | Terminal | Terminal |
130
+
| cmd3 | Piped | Terminal |
131
+
| cmd4 | Piped | Piped |
132
+
133
+
- (^cmd1 | ^cmd2; ^cmd3 | ^cmd4) o> test.out
134
+
135
+
| Command | Stdout | Stderr |
136
+
| ------- | -------- | -------- |
137
+
| cmd1 | Piped | Terminal |
138
+
| cmd2 | File | Terminal |
139
+
| cmd3 | Piped | Terminal |
140
+
| cmd4 | File | Terminal |
141
+
142
+
- (^cmd1 | ^cmd2; ^cmd3 | ^cmd4) e> test.out
143
+
144
+
| Command | Stdout | Stderr |
145
+
| ------- | -------- | -------- |
146
+
| cmd1 | Piped | File |
147
+
| cmd2 | Terminal | File |
148
+
| cmd3 | Piped | File |
149
+
| cmd4 | Terminal | File |
150
+
151
+
- (^cmd1 | ^cmd2; ^cmd3 | ^cmd4) o+e> test.out
152
+
153
+
| Command | Stdout | Stderr |
154
+
| ------- | -------- | -------- |
155
+
| cmd1 | Piped | File |
156
+
| cmd2 | File | File |
157
+
| cmd3 | Piped | File |
158
+
| cmd4 | File | File |
159
+
160
+
### Examples for custom command
161
+
Given the following custom commands
162
+
163
+
```nushell
164
+
def custom-cmd [] {
165
+
^cmd1 | ^cmd2
166
+
^cmd3 | ^cmd4
167
+
}
168
+
```
169
+
170
+
The custom command stdio behavior is the same as the previous section.
171
+
172
+
In the examples below the body of `custom-cmd` is `(^cmd1 | ^cmd2; ^cmd3 | ^cmd4)`.
173
+
174
+
- custom-cmd
175
+
176
+
| Command | Stdout | Stderr |
177
+
| ------- | -------- | ---------- |
178
+
| cmd1 | Piped | Terminal |
179
+
| cmd2 |*Terminal*| Terminal |
180
+
| cmd3 | Piped | Terminal |
181
+
| cmd4 | Terminal | Terminal |
182
+
183
+
- custom-cmd | ^cmd5
184
+
185
+
It runs `custom-cmd` first, then pipes *stdout* to `^cmd5`, where both stdout and stderr are directed to the Terminal.
186
+
187
+
| Command | Stdout | Stderr |
188
+
| ------- | -------- | ---------- |
189
+
| cmd1 | Piped | Terminal |
190
+
| cmd2 |*Terminal*| Terminal |
191
+
| cmd3 | Piped | Terminal |
192
+
| cmd4 | Piped | Terminal |
193
+
194
+
- custom-cmd e>| ^cmd5
195
+
196
+
It runs `custom-cmd` first, then pipes *stderr* to `^cmd5`, where both stdout and stderr are directed to the Terminal.
197
+
198
+
| Command | Stdout | Stderr |
199
+
| ------- | -------- | -------- |
200
+
| cmd1 | Piped | Terminal |
201
+
| cmd2 | Terminal | Terminal |
202
+
| cmd3 | Piped | Terminal |
203
+
| cmd4 | Terminal | Piped |
204
+
205
+
- custom-cmd o+e>| ^cmd5
206
+
207
+
It runs `custom-cmd` first, then pipes *stdout and stderr* to `^cmd5`, where both stdout and stderr are directed to the Terminal.
0 commit comments