unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: 45910@debbugs.gnu.org
Subject: [bug#45910] [PATCH] ui: Look up extensions before built-in commands.
Date: Thu, 28 Jan 2021 10:20:56 +0100	[thread overview]
Message-ID: <20210128092054.12811-1-rekado@elephly.net> (raw)
In-Reply-To: <20210116005708.22610-1-zimon.toutoune@gmail.com>

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(-)

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))))
-- 
2.29.2






  reply	other threads:[~2021-01-28  9:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-16  0:57 [bug#45910] [PATCH] ui: Switch precedence for extensions zimoun
2021-01-28  9:20 ` Ricardo Wurmus [this message]
2021-01-28 16:26   ` [bug#45910] [PATCH] ui: Look up extensions before built-in commands zimoun
2021-01-28 17:53     ` bug#45910: " Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210128092054.12811-1-rekado@elephly.net \
    --to=rekado@elephly.net \
    --cc=45910@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).