aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-12-13 21:13:16 +0100
committerLudovic Courtès <ludo@gnu.org>2015-12-13 21:13:16 +0100
commit20464dde13dc540951edc035d1af5d9fd756f2d1 (patch)
tree244c503a71db33f0a4978b4c5ee219998b14cda0
parentee2a7e3fd293b80d3b7f9b9a7949b8a74b2f0575 (diff)
downloadguix-20464dde13dc540951edc035d1af5d9fd756f2d1.tar
guix-20464dde13dc540951edc035d1af5d9fd756f2d1.tar.gz
guix build: Gracefully handle type errors in -e and -f.
* guix/scripts/build.scm (options->things-to-build)[validate-type]: New procedure. [ensure-list]: Use it.
-rw-r--r--guix/scripts/build.scm14
1 files changed, 10 insertions, 4 deletions
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index debf7c2848..a6596d0a82 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -404,10 +404,16 @@ must be one of 'package', 'all', or 'transitive'~%")
(define (options->things-to-build opts)
"Read the arguments from OPTS and return a list of high-level objects to
build---packages, gexps, derivations, and so on."
- (define ensure-list
- (match-lambda
- ((x ...) x)
- (x (list x))))
+ (define (validate-type x)
+ (unless (or (package? x) (derivation? x) (gexp? x) (procedure? x))
+ (leave (_ "~s: not something we can build~%") x)))
+
+ (define (ensure-list x)
+ (let ((lst (match x
+ ((x ...) x)
+ (x (list x)))))
+ (for-each validate-type lst)
+ lst))
(append-map (match-lambda
(('argument . (? string? spec))