1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 19:50:24 +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 should be closed explicitly when no longer needed, rather than letting
the garbage collector pick them up at some later time. the garbage collector pick them up at some later time.
@findex pipeline @deffn {Scheme Procedure} pipeline @var{commands}
@deffn {Scheme Procedure} pipeline commands Execute a pipeline of @var{commands}, where each command is a
Execute a @code{pipeline} of @var{commands} --- where each command is a list of a program and its arguments as strings, returning an input
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 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}. 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") (let ((commands '(("git" "ls-files")
("tar" "-cf-" "-T-") ("tar" "-cf-" "-T-")
("sha1sum" "-"))) ("sha1sum" "-")))
(pipe-fail? (lambda (pid) (success? (lambda (pid)
(not
(zero? (zero?
(status:exit-val (status:exit-val (cdr (waitpid pid)))))))
(cdr
(waitpid pid))))))))
(receive (from to pids) (pipeline commands) (receive (from to pids) (pipeline commands)
(let* ((sha1 (read-delimited " " from)) (let* ((sha1 (read-delimited " " from))
(index (list-index pipe-fail? (reverse pids)))) (index (list-index (negate success?) (reverse pids))))
(close to) (close to)
(close from) (close from)
(if (not index) sha1 (if (not index)
sha1
(string-append "pipeline failed in command: " (string-append "pipeline failed in command: "
(string-join (list-ref commands index))))))) (string-join (list-ref commands index)))))))
@result{} "52f99d234503fca8c84ef94b1005a3a28d8b3bc1" @result{} "52f99d234503fca8c84ef94b1005a3a28d8b3bc1"