From 20464dde13dc540951edc035d1af5d9fd756f2d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 13 Dec 2015 21:13:16 +0100 Subject: 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. --- guix/scripts/build.scm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'guix/scripts') 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)) -- cgit v1.2.3