split off util

This commit is contained in:
Rutger van Beusekom 2017-02-19 10:22:41 +01:00
parent 6b3351aa8a
commit bb68e4728c
3 changed files with 16 additions and 9 deletions

View File

@ -14,6 +14,7 @@
:use-module (sh pipe)
:use-module (sh peg)
:use-module (sh io)
:use-module (sh util)
:export (main))

View File

@ -9,8 +9,9 @@
:use-module (srfi srfi-26)
:use-module (sh io)
:use-module (sh util)
:export (pipeline job-control-init jobs report-jobs fg bg disjoin conjoin))
:export (pipeline job-control-init jobs report-jobs fg bg))
(define-record-type <process>
(make-process pid command status)
@ -164,14 +165,6 @@
(set! job-table (cons job job-table))
(if fg? (wait job))))
(define (disjoin . predicates)
(lambda (. arguments)
(any (cut apply <> arguments) predicates)))
(define (conjoin . predicates)
(lambda (. arguments)
(every (cut apply <> arguments) predicates)))
(define (reap-jobs)
(set! job-table (filter (disjoin job-running? job-stopped?) job-table)))

13
sh/util.scm Normal file
View File

@ -0,0 +1,13 @@
(define-module (sh util)
:use-module (srfi srfi-1)
:use-module (srfi srfi-26)
:export (disjoin conjoin))
(define (disjoin . predicates)
(lambda (. arguments)
(any (cut apply <> arguments) predicates)))
(define (conjoin . predicates)
(lambda (. arguments)
(every (cut apply <> arguments) predicates)))