Skip to content

Commit

Permalink
add reverse iteration for Cmd (JuliaLang#43498)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj authored and LilithHafner committed Mar 8, 2022
1 parent c4f3852 commit 3731d97
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ show(io::IO, p::Process) = print(io, "Process(", p.cmd, ", ", process_status(p),
for f in (:length, :firstindex, :lastindex, :keys, :first, :last, :iterate)
@eval $f(cmd::Cmd) = $f(cmd.exec)
end
Iterators.reverse(cmd::Cmd) = Iterators.reverse(cmd.exec)
eltype(::Type{Cmd}) = eltype(fieldtype(Cmd, :exec))
for f in (:iterate, :getindex)
@eval $f(cmd::Cmd, i) = $f(cmd.exec, i)
Expand Down
1 change: 1 addition & 0 deletions test/spawn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ end
# accessing the command elements as an array or iterator:
let c = `ls -l "foo bar"`
@test collect(c) == ["ls", "-l", "foo bar"]
@test collect(Iterators.reverse(c)) == reverse!(["ls", "-l", "foo bar"])
@test first(c) == "ls" == c[1]
@test last(c) == "foo bar" == c[3] == c[end]
@test c[1:2] == ["ls", "-l"]
Expand Down

0 comments on commit 3731d97

Please sign in to comment.