diff --git a/base/process.jl b/base/process.jl index 10c173e82b34c..4571f5ad2db01 100644 --- a/base/process.jl +++ b/base/process.jl @@ -641,6 +641,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) diff --git a/test/spawn.jl b/test/spawn.jl index 5007b7ef0f993..92232ba5d70f6 100644 --- a/test/spawn.jl +++ b/test/spawn.jl @@ -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"]