[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/04: guix gc: Error out when extra arguments are passed.
From: |
Ludovic Courtès |
Subject: |
02/04: guix gc: Error out when extra arguments are passed. |
Date: |
Wed, 11 Nov 2015 22:46:06 +0000 |
civodul pushed a commit to branch master
in repository guix.
commit 3a96d7c3dd864e4312df723ea54c2f710f55380c
Author: Ludovic Courtès <address@hidden>
Date: Wed Nov 11 23:05:43 2015 +0100
guix gc: Error out when extra arguments are passed.
Fixes <http://bugs.gnu.org/21817>.
Reported by Petter Berntsen <address@hidden>.
* 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.
---
guix/scripts/gc.scm | 7 +++++++
tests/guix-gc.sh | 8 +++++++-
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm
index 89a68d5..fe1bb93 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
diff --git a/tests/guix-gc.sh b/tests/guix-gc.sh
index c1eb66c..a100f18 100644
--- a/tests/guix-gc.sh
+++ b/tests/guix-gc.sh
@@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU
-# Copyright © 2013 Ludovic Courtès <address@hidden>
+# Copyright © 2013, 2015 Ludovic Courtès <address@hidden>
#
# This file is part of GNU Guix.
#
@@ -25,6 +25,12 @@ guix gc --version
trap "rm -f guix-gc-root" EXIT
rm -f guix-gc-root
+# For some operations, passing extra arguments is an error.
+for option in "" "-C 500M" "--verify" "--optimize"
+do
+ if guix gc $option whatever; then false; else true; fi
+done
+
# Check the references of a .drv.
drv="`guix build guile-bootstrap -d`"
out="`guix build guile-bootstrap`"