diff mbox series

[bug#45910] ui: Look up extensions before built-in commands.

Message ID 20210128092054.12811-1-rekado@elephly.net
State Accepted
Headers show
Series [bug#45910] ui: Look up extensions before built-in commands. | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Ricardo Wurmus Jan. 28, 2021, 9:20 a.m. UTC
From: zimoun <zimon.toutoune@gmail.com>

We can do without the extra throw here.  What do you think of this
simpler variant?

* guix/ui.scm (run-guix-command): Modify order so that extensions are allowed
to override default commands.

Co-authored-by: Ricardo Wurmus <rekado@elephly.net>
---
 guix/ui.scm | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

Comments

Simon Tournier Jan. 28, 2021, 4:26 p.m. UTC | #1
Hi Ricardo,

On Thu, 28 Jan 2021 at 10:20, Ricardo Wurmus <rekado@elephly.net> wrote:

> We can do without the extra throw here.  What do you think of this
> simpler variant?

Yeah that’s much better. :-)

Thanks,
simon
Ricardo Wurmus Jan. 28, 2021, 5:53 p.m. UTC | #2
Pushed!
diff mbox series

Patch

diff --git a/guix/ui.scm b/guix/ui.scm
index bd504c68da..45ae14f83c 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -2124,24 +2124,20 @@  Run COMMAND with ARGS.\n"))
   "Run COMMAND with the given ARGS.  Report an error when COMMAND is not
 found."
   (define module
-    (catch 'misc-error
-      (lambda ()
-        (resolve-interface `(guix scripts ,command)))
-      (lambda _
-        ;; Check if there is a matching extension.
-        (catch 'misc-error
-          (lambda ()
-            (match (search-path (extension-directories)
-                                (format #f "~a.scm" command))
-              (#f
-               (throw 'misc-error))
-              (file
-                (load file)
-                (resolve-interface `(guix extensions ,command)))))
-          (lambda _
-            (format (current-error-port)
-                    (G_ "guix: ~a: command not found~%") command)
-            (show-guix-usage))))))
+    ;; Check if there is a matching extension.
+    (match (search-path (extension-directories)
+                        (format #f "~a.scm" command))
+      (#f
+       (catch 'misc-error
+         (lambda ()
+           (resolve-interface `(guix scripts ,command)))
+         (lambda _
+           (format (current-error-port)
+                   (G_ "guix: ~a: command not found~%") command)
+           (show-guix-usage))))
+      (file
+       (load file)
+       (resolve-interface `(guix extensions ,command)))))
 
   (let ((command-main (module-ref module
                                   (symbol-append 'guix- command))))