Skip to content

Commit de3a70a

Browse files
authored
Advertise readchomp function more (#37806)
1 parent 110f125 commit de3a70a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

base/io.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Note that Julia does not convert the endianness for you. Use [`ntoh`](@ref) or
136136
137137
read(io::IO, String)
138138
139-
Read the entirety of `io`, as a `String`.
139+
Read the entirety of `io`, as a `String` (see also [`readchomp`](@ref)).
140140
141141
# Examples
142142
```jldoctest

doc/src/manual/running-external-programs.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ The `hello` is the output of the `echo` command, sent to [`stdout`](@ref). The r
3737
returns `nothing`, and throws an [`ErrorException`](@ref) if the external command fails to run
3838
successfully.
3939

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

4243
```jldoctest
43-
julia> a = read(`echo hello`, String)
44+
julia> read(`echo hello`, String)
4445
"hello\n"
4546
46-
julia> chomp(a) == "hello"
47-
true
47+
julia> readchomp(`echo hello`)
48+
"hello"
4849
```
4950

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

0 commit comments

Comments
 (0)