Skip to content

Commit

Permalink
Rename pipe -> pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Jul 17, 2015
1 parent c448fb1 commit 2eae18b
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 46 deletions.
21 changes: 11 additions & 10 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,17 @@ const MemoryError = OutOfMemoryError
#9295
@deprecate push!(t::Associative, key, v) setindex!(t, v, key)

@deprecate (|>)(src::AbstractCmd, dest::AbstractCmd) pipe(src, dest)
@deprecate (.>)(src::AbstractCmd, dest::AbstractCmd) pipe(src, stderr=dest)
@deprecate (|>)(src::Redirectable, dest::AbstractCmd) pipe(src, dest)
@deprecate (|>)(src::AbstractCmd, dest::Redirectable) pipe(src, dest)
@deprecate (.>)(src::AbstractCmd, dest::Redirectable) pipe(src, stderr=dest)
@deprecate (|>)(src::AbstractCmd, dest::AbstractString) pipe(src, dest)
@deprecate (|>)(src::AbstractString, dest::AbstractCmd) pipe(src, dest)
@deprecate (.>)(src::AbstractCmd, dest::AbstractString) pipe(src, stderr=dest)
@deprecate (>>)(src::AbstractCmd, dest::AbstractString) pipe(src, stdout=dest, append=true)
@deprecate (.>>)(src::AbstractCmd, dest::AbstractString) pipe(src, stderr=dest, append=true)
@deprecate (|>)(src::AbstractCmd, dest::AbstractCmd) pipeline(src, dest)
@deprecate (.>)(src::AbstractCmd, dest::AbstractCmd) pipeline(src, stderr=dest)
@deprecate (|>)(src::Redirectable, dest::AbstractCmd) pipeline(src, dest)
@deprecate (|>)(src::AbstractCmd, dest::Redirectable) pipeline(src, dest)
@deprecate (.>)(src::AbstractCmd, dest::Redirectable) pipeline(src, stderr=dest)
@deprecate (|>)(src::AbstractCmd, dest::AbstractString) pipeline(src, dest)
@deprecate (|>)(src::AbstractString, dest::AbstractCmd) pipeline(src, dest)
@deprecate (.>)(src::AbstractCmd, dest::AbstractString) pipeline(src, stderr=dest)
@deprecate (>>)(src::AbstractCmd, dest::AbstractString) pipeline(src, stdout=dest, append=true)
@deprecate (.>>)(src::AbstractCmd, dest::AbstractString) pipeline(src, stderr=dest, append=true)
@deprecate pipe pipeline

# 10314
@deprecate filter!(r::Regex, d::Dict) filter!((k,v)->ismatch(r,k), d)
Expand Down
2 changes: 1 addition & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ export
nb_available,
ntoh,
open,
pipe,
pipeline,
Pipe,
PipeBuffer,
poll_fd,
Expand Down
6 changes: 3 additions & 3 deletions base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ end
global _clipboardcmd
_clipboardcmd !== nothing && return _clipboardcmd
for cmd in (:xclip, :xsel)
success(pipe(`which $cmd`, DevNull)) && return _clipboardcmd = cmd
success(pipeline(`which $cmd`, DevNull)) && return _clipboardcmd = cmd
end
error("no clipboard command found, please install xsel or xclip")
end
Expand Down Expand Up @@ -163,7 +163,7 @@ function versioninfo(io::IO=STDOUT, verbose::Bool=false)
println(io, " WORD_SIZE: ", Sys.WORD_SIZE)
if verbose
lsb = ""
@linux_only try lsb = readchomp(pipe(`lsb_release -ds`, stderr=DevNull)) end
@linux_only try lsb = readchomp(pipeline(`lsb_release -ds`, stderr=DevNull)) end
@windows_only try lsb = strip(readall(`$(ENV["COMSPEC"]) /c ver`)) end
if lsb != ""
println(io, " ", lsb)
Expand Down Expand Up @@ -341,7 +341,7 @@ downloadcmd = nothing
global downloadcmd
if downloadcmd === nothing
for checkcmd in (:curl, :wget, :fetch)
if success(pipe(`which $checkcmd`, DevNull))
if success(pipeline(`which $checkcmd`, DevNull))
downloadcmd = checkcmd
break
end
Expand Down
2 changes: 1 addition & 1 deletion base/pkg/entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function add(pkg::AbstractString, vers::VersionSet)
outdated = :yes
else
try
run(pipe(Git.cmd(`fetch -q --all`, dir="METADATA"),stdout=DevNull,stderr=DevNull))
run(pipeline(Git.cmd(`fetch -q --all`, dir="METADATA"),stdout=DevNull,stderr=DevNull))
outdated = Git.success(`diff --quiet origin/$branch`, dir="METADATA") ?
(:no) : (:yes)
end
Expand Down
2 changes: 1 addition & 1 deletion base/pkg/generate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ github_user() = readchomp(ignorestatus(`git config --global --get github.user`))
function git_contributors(dir::AbstractString, n::Int=typemax(Int))
contrib = Dict()
tty = @windows? "CON:" : "/dev/tty"
for line in eachline(pipe(tty, Git.cmd(`shortlog -nes`, dir=dir)))
for line in eachline(pipeline(tty, Git.cmd(`shortlog -nes`, dir=dir)))
m = match(r"\s*(\d+)\s+(.+?)\s+\<(.+?)\>\s*$", line)
m == nothing && continue
commits, name, email = m.captures
Expand Down
2 changes: 1 addition & 1 deletion base/pkg/git.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function git(d)
end

cmd(args::Cmd; dir="") = `$(git(dir)) $args`
run(args::Cmd; dir="", out=STDOUT) = Base.run(pipe(cmd(args,dir=dir), out))
run(args::Cmd; dir="", out=STDOUT) = Base.run(pipeline(cmd(args,dir=dir), out))
readall(args::Cmd; dir="") = Base.readall(cmd(args,dir=dir))
readchomp(args::Cmd; dir="") = Base.readchomp(cmd(args,dir=dir))

Expand Down
12 changes: 6 additions & 6 deletions base/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function show(io::IO, cmd::Cmd)
end

function show(io::IO, cmds::Union{OrCmds,ErrOrCmds})
print(io, "pipe(")
print(io, "pipeline(")
show(io, cmds.a)
print(io, ", ")
print(io, isa(cmds, ErrOrCmds) ? "stderr=" : "stdout=")
Expand Down Expand Up @@ -100,7 +100,7 @@ type CmdRedirect <: AbstractCmd
end

function show(io::IO, cr::CmdRedirect)
print(io, "pipe(")
print(io, "pipeline(")
show(io, cr.cmd)
print(io, ", ")
if cr.stream_no == STDOUT_NO
Expand Down Expand Up @@ -149,7 +149,7 @@ redir_err(src::AbstractCmd, dest::AbstractString) = CmdRedirect(src, FileRedirec
redir_out_append(src::AbstractCmd, dest::AbstractString) = CmdRedirect(src, FileRedirect(dest, true), STDOUT_NO)
redir_err_append(src::AbstractCmd, dest::AbstractString) = CmdRedirect(src, FileRedirect(dest, true), STDERR_NO)

function pipe(cmd::AbstractCmd; stdin=nothing, stdout=nothing, stderr=nothing, append::Bool=false)
function pipeline(cmd::AbstractCmd; stdin=nothing, stdout=nothing, stderr=nothing, append::Bool=false)
if append && stdout === nothing && stderr === nothing
error("append set to true, but no output redirections specified")
end
Expand All @@ -165,10 +165,10 @@ function pipe(cmd::AbstractCmd; stdin=nothing, stdout=nothing, stderr=nothing, a
return cmd
end

pipe(cmd::AbstractCmd, dest) = pipe(cmd, stdout=dest)
pipe(src::Union{Redirectable,AbstractString}, cmd::AbstractCmd) = pipe(cmd, stdin=src)
pipeline(cmd::AbstractCmd, dest) = pipeline(cmd, stdout=dest)
pipeline(src::Union{Redirectable,AbstractString}, cmd::AbstractCmd) = pipeline(cmd, stdin=src)

pipe(a, b, c, d...) = pipe(pipe(a,b), c, d...)
pipeline(a, b, c, d...) = pipeline(pipeline(a,b), c, d...)

typealias RawOrBoxedHandle Union{UVHandle,AsyncStream,Redirectable,IOStream}
typealias StdIOSet NTuple{3,RawOrBoxedHandle}
Expand Down
2 changes: 1 addition & 1 deletion base/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function make_seed()
seed = reinterpret(UInt64, time())
seed = hash(seed, UInt64(getpid()))
try
seed = hash(seed, parse(UInt64, readall(pipe(`ifconfig`, `sha1sum`))[1:40], 16))
seed = hash(seed, parse(UInt64, readall(pipeline(`ifconfig`, `sha1sum`))[1:40], 16))
end
return make_seed(seed)
end
Expand Down
42 changes: 21 additions & 21 deletions test/spawn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ yes = `perl -le 'while (1) {print STDOUT "y"}'`
#### Examples used in the manual ####

@test readall(`echo hello | sort`) == "hello | sort\n"
@test readall(pipe(`echo hello`, `sort`)) == "hello\n"
@test length(spawn(pipe(`echo hello`, `sort`)).processes) == 2
@test readall(pipeline(`echo hello`, `sort`)) == "hello\n"
@test length(spawn(pipeline(`echo hello`, `sort`)).processes) == 2

out = readall(`echo hello` & `echo world`)
@test search(out,"world") != (0,0)
@test search(out,"hello") != (0,0)
@test readall(pipe(`echo hello` & `echo world`, `sort`)) == "hello\nworld\n"
@test readall(pipeline(`echo hello` & `echo world`, `sort`)) == "hello\nworld\n"

@test (run(`printf " \033[34m[stdio passthrough ok]\033[0m\n"`); true)

# Test for SIGPIPE being treated as normal termination (throws an error if broken)
@unix_only @test (run(pipe(yes,`head`,DevNull)); true)
@unix_only @test (run(pipeline(yes,`head`,DevNull)); true)

begin
a = Base.Condition()
@schedule begin
p = spawn(pipe(yes,DevNull))
p = spawn(pipeline(yes,DevNull))
Base.notify(a,p)
@test !success(p)
end
Expand All @@ -51,30 +51,30 @@ end

if false
prefixer(prefix, sleep) = `perl -nle '$|=1; print "'$prefix' ", $_; sleep '$sleep';'`
@test success(pipe(`perl -le '$|=1; for(0..2){ print; sleep 1 }'`,
@test success(pipeline(`perl -le '$|=1; for(0..2){ print; sleep 1 }'`,
prefixer("A",2) & prefixer("B",2)))
@test success(pipe(`perl -le '$|=1; for(0..2){ print; sleep 1 }'`,
@test success(pipeline(`perl -le '$|=1; for(0..2){ print; sleep 1 }'`,
prefixer("X",3) & prefixer("Y",3) & prefixer("Z",3),
prefixer("A",2) & prefixer("B",2)))
end

@test success(`true`)
@test !success(`false`)
@test success(pipe(`true`, `true`))
@test success(pipeline(`true`, `true`))
if false
@test success(ignorestatus(`false`))
@test success(pipe(ignorestatus(`false`), `true`))
@test !success(pipe(ignorestatus(`false`), `false`))
@test success(pipeline(ignorestatus(`false`), `true`))
@test !success(pipeline(ignorestatus(`false`), `false`))
@test !success(ignorestatus(`false`) & `false`)
@test success(ignorestatus(pipe(`false`, `false`)))
@test success(ignorestatus(pipeline(`false`, `false`)))
@test success(ignorestatus(`false` & `false`))
end

# STDIN Redirection
file = tempname()
run(pipe(`echo hello world`, file))
@test readall(pipe(file, `cat`)) == "hello world\n"
@test open(readall, pipe(file, `cat`), "r") == "hello world\n"
run(pipeline(`echo hello world`, file))
@test readall(pipeline(file, `cat`)) == "hello world\n"
@test open(readall, pipeline(file, `cat`), "r") == "hello world\n"
rm(file)

# Stream Redirection
Expand All @@ -84,12 +84,12 @@ rm(file)
port, server = listenany(2326)
put!(r,port)
client = accept(server)
@test readall(pipe(client, `cat`)) == "hello world\n"
@test readall(pipeline(client, `cat`)) == "hello world\n"
close(server)
end
@async begin
sock = connect(fetch(r))
run(pipe(`echo hello world`, sock))
run(pipeline(`echo hello world`, sock))
close(sock)
end
end
Expand Down Expand Up @@ -118,7 +118,7 @@ str2 = readall(stdout)

# This test hangs if the end of run walk across uv streams calls shutdown on a stream that is shutting down.
file = tempname()
open(pipe(`cat -`, file), "w") do io
open(pipeline(`cat -`, file), "w") do io
write(io, str)
end
rm(file)
Expand Down Expand Up @@ -173,17 +173,17 @@ exename = joinpath(JULIA_HOME, Base.julia_exename())
if valgrind_off
# If --trace-children=yes is passed to valgrind, we will get a
# valgrind banner here, not "Hello World\n".
@test readall(pipe(`$exename -f -e 'println(STDERR,"Hello World")'`, stderr=`cat`)) == "Hello World\n"
@test readall(pipeline(`$exename -f -e 'println(STDERR,"Hello World")'`, stderr=`cat`)) == "Hello World\n"
p = Pipe()
run(pipe(`$exename -f -e 'println(STDERR,"Hello World")'`, stderr = p))
run(pipeline(`$exename -f -e 'println(STDERR,"Hello World")'`, stderr = p))
@test readall(p) == "Hello World\n"
end

# issue #6310
@test readall(pipe(`echo "2+2"`, `$exename -f`)) == "4\n"
@test readall(pipeline(`echo "2+2"`, `$exename -f`)) == "4\n"

# issue #5904
@test run(pipe(ignorestatus(`false`), `true`)) === nothing
@test run(pipeline(ignorestatus(`false`), `true`)) === nothing


# issue #6010
Expand Down
2 changes: 1 addition & 1 deletion test/strings/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ else
for encoding in ["UTF-32LE", "UTF-16BE", "UTF-16LE", "UTF-8"]
output_path = joinpath(unicodedir, encoding*".unicode")
f = Base.FS.open(output_path,Base.JL_O_WRONLY|Base.JL_O_CREAT,Base.S_IRUSR | Base.S_IWUSR | Base.S_IRGRP | Base.S_IROTH)
run(pipe(`iconv -f $primary_encoding -t $encoding $primary_path`, f))
run(pipeline(`iconv -f $primary_encoding -t $encoding $primary_path`, f))
Base.FS.close(f)
end

Expand Down

0 comments on commit 2eae18b

Please sign in to comment.