Repository navigation
shell: Allow duplicating output fds (e.g. 2>&1) - #9004
Conversation
|
✅ test failures on bun-darwin-aarch64 have been resolved. |
|
❌ @zackradisic 1 files with test failures on linux-x64:
|
|
❌ @zackradisic 2 files with test failures on linux-x64-baseline:
|
❌🪟 @zackradisic, there are 18 test regressions on Windows x86_64
|
| const std = @import("std"); | ||
| const bun = @import("root").bun; | ||
|
|
||
| pub fn search(str: anytype, needle: anytype) ?usize {} |
|
Can you add this to the docs to explain its supported? Along with stdin redirection |
|
❌ @zackradisic 1 files with test failures on bun-darwin-x64:
|
| - `Bun.file(path)`, `Bun.file(fd)` (reads from the file) | ||
| - `Response` (reads from the body) | ||
|
|
||
| ### To/From Files |
There was a problem hiding this comment.
Maybe a section on Redirects?
And then
Redirecting stdout → file
Redirecting stderr → file
Redirecting stdin ← file
Redirecting stdout → stderr
Redirecting stdout ← stderr
There was a problem hiding this comment.
basically, people might not immediately make the mental leap that stdout and stderr are a "file"
Also, we could do buffers in there too.
| @@ -1463,6 +1465,7 @@ pub fn NewShellSubprocess(comptime EventLoopKind: JSC.EventLoopKind, comptime Sh | |||
| spawn_args.stdio[2].setUpChildIoPosixSpawn( | |||
| &actions, | |||
| stderr_pipe, | |||
There was a problem hiding this comment.
stderr_pipe,
stderr_pipe
|
|
||
| await TestBuilder.command`echo foo bar > file.txt; cat < file.txt`.ensureTempDir().stdout("foo bar\n").run(); | ||
|
|
||
| await TestBuilder.command`BUN_DEBUG_QUIET_LOGS=1 ${BUN} -e ${"console.log('Stdout'); console.error('Stderr')"} 2>&1` |
There was a problem hiding this comment.
you can remove BUN_DEBUG_QUIET_LOGS from these, it should do that automatically now
What does this PR do?
This PR enables support for the "Duplicating an Output File Descriptor" syntax (e.g.
2>&1)Only the stdout/stderr fds are supported right now. So you can redirect stderr to stdout
2>&1, or redirect stdout to stderr1>&2How did you verify your code works?
Zig files changed:
bun-debug test test-file-name.test)