From patchwork Thu Jan 28 09:20:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Wurmus X-Patchwork-Id: 26698 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id AB06F27BC1C; Thu, 28 Jan 2021 09:23:11 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id BB75127BC1D for ; Thu, 28 Jan 2021 09:23:10 +0000 (GMT) Received: from localhost ([::1]:46552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l53W9-0006Ct-Ox for patchwork@mira.cbaines.net; Thu, 28 Jan 2021 04:23:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l53W2-0006Ci-Sn for guix-patches@gnu.org; Thu, 28 Jan 2021 04:23:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l53W2-0008Uy-Lo for guix-patches@gnu.org; Thu, 28 Jan 2021 04:23:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l53W2-0004rr-IJ for guix-patches@gnu.org; Thu, 28 Jan 2021 04:23:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45910] [PATCH] ui: Look up extensions before built-in commands. References: <20210116005708.22610-1-zimon.toutoune@gmail.com> In-Reply-To: <20210116005708.22610-1-zimon.toutoune@gmail.com> Resent-From: Ricardo Wurmus Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 28 Jan 2021 09:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45910 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 45910@debbugs.gnu.org Received: via spool by 45910-submit@debbugs.gnu.org id=B45910.161182573118635 (code B ref 45910); Thu, 28 Jan 2021 09:23:02 +0000 Received: (at 45910) by debbugs.gnu.org; 28 Jan 2021 09:22:11 +0000 Received: from localhost ([127.0.0.1]:47245 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l53VC-0004qT-Qy for submit@debbugs.gnu.org; Thu, 28 Jan 2021 04:22:11 -0500 Received: from sender4-of-o51.zoho.com ([136.143.188.51]:21104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l53VA-0004qJ-An for 45910@debbugs.gnu.org; Thu, 28 Jan 2021 04:22:09 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1611825724; cv=none; d=zohomail.com; s=zohoarc; b=nQ0K54tlvoClWnHSm3bVq8YiyQtnYn25SDLMFHGEejjnc4xjkUgnDyTGAouuP7zCQqtyWTeJfJFrUXC5SXJtl4Z0lEb+qCVcPql8SptUG9OS7H9UiKIt1tcor7BoTmUEClA9c2BZVu97/9/YP79v1jNPKp0zm/xdZ49rWZYMGe4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611825724; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=qNFIqoM7daVq/hmEwT9uCO7Pz0kLsYGcIlPyV5UnGMY=; b=XkyPD6WkO0lOFBJP7HIjMD6nrEALR6ZfZzGZ9S4BOMI50vV43HnC5SQw54bOHeiZ7kYd2oXIHZh7hlVKJGl4/9wn1/oFC5CCyDDYOVFLKzcdDQvcg2q4LW+2PUqL7rbw5lzmUkQYAFjs7KYsb2yYd8x6HqRCQUAEEGff7M8jicM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1611825724; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=qNFIqoM7daVq/hmEwT9uCO7Pz0kLsYGcIlPyV5UnGMY=; b=bXNJ7zCcWRdr/n2ikDW40Fxvw0SrDyAopspGXkUhIWxwi8Dzqma5LWkd/NTW6aAU eElVQxZnFjY858qna8ji0AB3XQMACTOASl/6glvZYebmNTpGV5qiEJAjtaOE43Gw4gF JxvhCoR5Y4u+2sGL/3irZOPUTThAN+81bKcia2j8= Received: from localhost (p54ad4fb2.dip0.t-ipconnect.de [84.173.79.178]) by mx.zohomail.com with SMTPS id 1611825722412278.7251652640243; Thu, 28 Jan 2021 01:22:02 -0800 (PST) From: Ricardo Wurmus Message-ID: <20210128092054.12811-1-rekado@elephly.net> Date: Thu, 28 Jan 2021 10:20:56 +0100 X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-ZohoMailClient: External X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: zimoun 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 --- 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))))