Test (and bugfix) conditions
This commit is contained in:
parent
875ce167e9
commit
dba8ca3153
2 changed files with 12 additions and 9 deletions
|
@ -1,8 +1,9 @@
|
|||
(define-module (ordo condition)
|
||||
#:use-moudle (ordo context)
|
||||
#:use-module (srfi srfi-71)
|
||||
#:use-module (ordo context)
|
||||
#:use-module (ordo action filesystem))
|
||||
|
||||
(define (cond:any preds)
|
||||
(define-public (cond:any preds)
|
||||
(lambda (ctx)
|
||||
(let loop ((preds preds))
|
||||
(if (null? preds)
|
||||
|
@ -12,7 +13,7 @@
|
|||
#t
|
||||
(loop (cdr preds))))))))
|
||||
|
||||
(define (cond:every preds)
|
||||
(define-public (cond:every preds)
|
||||
(lambda (ctx)
|
||||
(let loop ((preds preds))
|
||||
(if (null? preds)
|
||||
|
@ -22,17 +23,17 @@
|
|||
(loop (cdr preds))
|
||||
#f))))))
|
||||
|
||||
(define (cond:command-available? cmd-name)
|
||||
(define-public (cond:command-available? cmd-name)
|
||||
(lambda (ctx)
|
||||
(let ((_ rc) (run "which" `(,cmd-name)))
|
||||
(let ((_ rc (run "which" `(,cmd-name))))
|
||||
(zero? rc))))
|
||||
|
||||
(define (cond:directory? path)
|
||||
(define-public (cond:directory? path)
|
||||
(lambda (ctx)
|
||||
(let ((st ((action:stat path) ctx)))
|
||||
(and st (string=? "directory" (assoc-ref st 'file-type))))))
|
||||
|
||||
(define (cond:regular-file? path)
|
||||
(define-public (cond:regular-file? path)
|
||||
(lambda (ctx)
|
||||
(let ((st ((action:stat path) ctx)))
|
||||
(and st (string=? "regular-file" (assoc-ref st 'file-type))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue