Skip to content

Commit 69260e5

Browse files
stevengjLilithHafner
authored andcommitted
add reverse iteration for Cmd (JuliaLang#43498)
1 parent e4db242 commit 69260e5

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

base/process.jl

+1
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ show(io::IO, p::Process) = print(io, "Process(", p.cmd, ", ", process_status(p),
654654
for f in (:length, :firstindex, :lastindex, :keys, :first, :last, :iterate)
655655
@eval $f(cmd::Cmd) = $f(cmd.exec)
656656
end
657+
Iterators.reverse(cmd::Cmd) = Iterators.reverse(cmd.exec)
657658
eltype(::Type{Cmd}) = eltype(fieldtype(Cmd, :exec))
658659
for f in (:iterate, :getindex)
659660
@eval $f(cmd::Cmd, i) = $f(cmd.exec, i)

test/spawn.jl

+1
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ end
599599
# accessing the command elements as an array or iterator:
600600
let c = `ls -l "foo bar"`
601601
@test collect(c) == ["ls", "-l", "foo bar"]
602+
@test collect(Iterators.reverse(c)) == reverse!(["ls", "-l", "foo bar"])
602603
@test first(c) == "ls" == c[1]
603604
@test last(c) == "foo bar" == c[3] == c[end]
604605
@test c[1:2] == ["ls", "-l"]

0 commit comments

Comments
 (0)