guix package: Exit with 1 when a generation cannot be listed.
authorNikita Karetnikov <nikita@karetnikov.org>
Tue, 24 Sep 2013 22:11:16 +0000 (22:11 +0000)
committerNikita Karetnikov <nikita@karetnikov.org>
Wed, 25 Sep 2013 16:07:50 +0000 (16:07 +0000)
* guix/scripts/package.scm (guix-package)[process-query]: Exit with 1
  when a generation does not exist or the profile points to the zeroth
  generation.
* tests/guix-package.sh: Test the former case.

guix/scripts/package.scm
tests/guix-package.sh

index 1d00e39..1f21890 100644 (file)
@@ -977,11 +977,16 @@ more information.~%"))
                 (leave (_ "profile '~a' does not exist~%")
                        profile))
                ((string-null? pattern)
-                (for-each list-generation
-                          (generation-numbers profile)))
+                (let ((numbers (generation-numbers profile)))
+                  (if (equal? numbers '(0))
+                      (exit 1)
+                      (for-each list-generation numbers))))
                ((matching-generations pattern profile)
                 =>
-                (cut for-each list-generation <>))
+                (lambda (numbers)
+                  (if (null-list? numbers)
+                      (exit 1)
+                      (for-each list-generation numbers))))
                (else
                 (leave (_ "invalid syntax: ~a~%")
                        pattern)))
index b09a9c0..f1f7ee6 100644 (file)
@@ -85,6 +85,10 @@ then
     test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \
         = "  guile-bootstrap"
 
+    # Exit with 1 when a generation does not exist.
+    if guix package -p "$profile" --list-generations=42;
+    then false; else true; fi
+
     # Remove a package.
     guix package --bootstrap -p "$profile" -r "guile-bootstrap"
     test -L "$profile-3-link"