summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-11-11 23:05:43 +0100
committerLudovic Courtès <ludo@gnu.org>2015-11-11 23:29:20 +0100
commit3a96d7c3dd864e4312df723ea54c2f710f55380c (patch)
tree7e8ec13fadda544f33c095e8742314210c4db6a0 /guix
parent6237b9fa39c6ab3283c50b96520b990c8612abc1 (diff)
guix gc: Error out when extra arguments are passed.
Fixes <http://bugs.gnu.org/21817>. Reported by Petter Berntsen <petter@mykolab.ch>. * guix/scripts/gc.scm (guix-gc)[assert-no-extra-arguments]: New procedure. Use it for actions 'collect-garbage', 'optimize', and 'verify'. * tests/guix-gc.sh: Add tests.
Diffstat (limited to 'guix')
-rw-r--r--guix/scripts/gc.scm7
1 files changed, 7 insertions, 0 deletions
diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm
index 89a68d51d0..fe1bb93f7f 100644
--- a/guix/scripts/gc.scm
+++ b/guix/scripts/gc.scm
@@ -182,6 +182,10 @@ Invoke the garbage collector.\n"))
(('argument . arg) arg)
(_ #f))
opts)))
+ (define (assert-no-extra-arguments)
+ (unless (null? paths)
+ (leave (_ "extraneous arguments: ~{~a ~}~%") paths)))
+
(define (list-relatives relatives)
(for-each (compose (lambda (path)
(for-each (cut simple-format #t "~a~%" <>)
@@ -192,6 +196,7 @@ Invoke the garbage collector.\n"))
(case (assoc-ref opts 'action)
((collect-garbage)
+ (assert-no-extra-arguments)
(let ((min-freed (assoc-ref opts 'min-freed)))
(if min-freed
(collect-garbage store min-freed)
@@ -205,8 +210,10 @@ Invoke the garbage collector.\n"))
((list-referrers)
(list-relatives referrers))
((optimize)
+ (assert-no-extra-arguments)
(optimize-store store))
((verify)
+ (assert-no-extra-arguments)
(let ((options (assoc-ref opts 'verify-options)))
(exit
(verify-store store