Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ New library functions
New library features
--------------------

* The `redirect_*` functions can now be called on `IOContext` objects.

Standard library changes
------------------------
Expand Down
6 changes: 6 additions & 0 deletions base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,12 @@ for (x, writable, unix_fd, c_symbol) in
$x = devnull
return devnull
end
function ($f)(io::IOContext)
io2, _dict = unwrapcontext(io)
($f)(io2)
global $x = io
return io
end
end
end

Expand Down
5 changes: 5 additions & 0 deletions test/spawn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ end
@test "Hello World\n" == read(fname, String)
@test OLD_STDOUT === stdout
rm(fname)

col = get(stdout, :color, false)
redirect_stdout(IOContext(stdout, :color=>!col))
@test get(stdout, :color, col) == !col
redirect_stdout(OLD_STDOUT)
end
end

Expand Down