1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

doc: Tweak 'pipeline' documentation.

* doc/ref/posix.texi (Pipes): Adjust markup.  Simplify example.
This commit is contained in:
Ludovic Courtès 2020-05-16 22:35:33 +02:00
parent 9971861851
commit 0e912cee24

View file

@ -2370,10 +2370,9 @@ processes, and a system-wide limit on the number of pipes, so pipes
should be closed explicitly when no longer needed, rather than letting
the garbage collector pick them up at some later time.
@findex pipeline
@deffn {Scheme Procedure} pipeline commands
Execute a @code{pipeline} of @var{commands} --- where each command is a
list of a program and its arguments as strings --- returning an input
@deffn {Scheme Procedure} pipeline @var{commands}
Execute a pipeline of @var{commands}, where each command is a
list of a program and its arguments as strings, returning an input
port to the end of the pipeline, an output port to the beginning of the
pipeline and a list of PIDs of the processes executing the @var{commands}.
@ -2381,18 +2380,16 @@ pipeline and a list of PIDs of the processes executing the @var{commands}.
(let ((commands '(("git" "ls-files")
("tar" "-cf-" "-T-")
("sha1sum" "-")))
(pipe-fail? (lambda (pid)
(not
(zero?
(status:exit-val
(cdr
(waitpid pid))))))))
(success? (lambda (pid)
(zero?
(status:exit-val (cdr (waitpid pid)))))))
(receive (from to pids) (pipeline commands)
(let* ((sha1 (read-delimited " " from))
(index (list-index pipe-fail? (reverse pids))))
(index (list-index (negate success?) (reverse pids))))
(close to)
(close from)
(if (not index) sha1
(if (not index)
sha1
(string-append "pipeline failed in command: "
(string-join (list-ref commands index)))))))
@result{} "52f99d234503fca8c84ef94b1005a3a28d8b3bc1"