Skip to content

Commit

Permalink
Advertise readchomp function more (#37806)
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad authored Nov 16, 2020
1 parent 110f125 commit de3a70a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Note that Julia does not convert the endianness for you. Use [`ntoh`](@ref) or
read(io::IO, String)
Read the entirety of `io`, as a `String`.
Read the entirety of `io`, as a `String` (see also [`readchomp`](@ref)).
# Examples
```jldoctest
Expand Down
9 changes: 5 additions & 4 deletions doc/src/manual/running-external-programs.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ The `hello` is the output of the `echo` command, sent to [`stdout`](@ref). The r
returns `nothing`, and throws an [`ErrorException`](@ref) if the external command fails to run
successfully.

If you want to read the output of the external command, [`read`](@ref) can be used instead:
If you want to read the output of the external command, [`read`](@ref) or [`readchomp`](@ref)
can be used instead:

```jldoctest
julia> a = read(`echo hello`, String)
julia> read(`echo hello`, String)
"hello\n"
julia> chomp(a) == "hello"
true
julia> readchomp(`echo hello`)
"hello"
```

More generally, you can use [`open`](@ref) to read from or write to an external command.
Expand Down

0 comments on commit de3a70a

Please sign in to comment.