summaryrefslogtreecommitdiff
path: root/guix/scripts/gc.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-12-18 22:33:51 +0100
committerLudovic Courtès <ludo@gnu.org>2017-12-18 23:17:30 +0100
commit3caab236c49012643ab46afd7e82a287ec413ee8 (patch)
tree53a3f2d81cd2db5aaa0cbb19321c3230170a64c0 /guix/scripts/gc.scm
parent147d42fc0362160baf50bdc71ab918c1e1db2f88 (diff)
downloadguix-patches-3caab236c49012643ab46afd7e82a287ec413ee8.tar
guix-patches-3caab236c49012643ab46afd7e82a287ec413ee8.tar.gz
guix gc: '--verify=foo' is reported as an error.
Fixes <https://bugs.gnu.org/29761>. Reported by Martin Castillo <castilma@uni-bremen.de>. * guix/scripts/gc.scm (argument->verify-options): New procedure. (%options) ["verify"]: Adjust to use it. * tests/guix-gc.sh: Add test.
Diffstat (limited to 'guix/scripts/gc.scm')
-rw-r--r--guix/scripts/gc.scm31
1 files changed, 21 insertions, 10 deletions
diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm
index 378a47d113..a31d2236b0 100644
--- a/guix/scripts/gc.scm
+++ b/guix/scripts/gc.scm
@@ -78,6 +78,21 @@ Invoke the garbage collector.\n"))
(newline)
(show-bug-report-information))
+(define argument->verify-options
+ (let ((not-comma (char-set-complement (char-set #\,)))
+ (validate (lambda (option)
+ (unless (memq option '(repair contents))
+ (leave (G_ "~a: invalid '--verify' option~%")
+ option)))))
+ (lambda (arg)
+ "Turn ARG into a list of symbols denoting '--verify' options."
+ (if arg
+ (let ((lst (map string->symbol
+ (string-tokenize arg not-comma))))
+ (for-each validate lst)
+ lst)
+ '()))))
+
(define %options
;; Specification of the command-line options.
(list (option '(#\h "help") #f #f
@@ -112,16 +127,12 @@ Invoke the garbage collector.\n"))
(alist-cons 'action 'optimize
(alist-delete 'action result))))
(option '("verify") #f #t
- (let ((not-comma (char-set-complement (char-set #\,))))
- (lambda (opt name arg result)
- (let ((options (if arg
- (map string->symbol
- (string-tokenize arg not-comma))
- '())))
- (alist-cons 'action 'verify
- (alist-cons 'verify-options options
- (alist-delete 'action
- result)))))))
+ (lambda (opt name arg result)
+ (let ((options (argument->verify-options arg)))
+ (alist-cons 'action 'verify
+ (alist-cons 'verify-options options
+ (alist-delete 'action
+ result))))))
(option '("list-dead") #f #f
(lambda (opt name arg result)
(alist-cons 'action 'list-dead