From patchwork Tue Oct 19 10:13:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 33947 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 29BB627BBE3; Tue, 19 Oct 2021 11:18:05 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS 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 E647C27BBE1 for ; Tue, 19 Oct 2021 11:18:04 +0100 (BST) Received: from localhost ([::1]:57544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcmC4-0001E1-1m for patchwork@mira.cbaines.net; Tue, 19 Oct 2021 06:18:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcm8B-0003xP-1E for guix-patches@gnu.org; Tue, 19 Oct 2021 06:14:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37917) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcm8A-0007nr-KF for guix-patches@gnu.org; Tue, 19 Oct 2021 06:14:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mcm8A-0007Ic-Fo for guix-patches@gnu.org; Tue, 19 Oct 2021 06:14:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51285] [PATCH 3/3] shell: Suggest running '--check' once for interactive use. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 19 Oct 2021 10:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51285 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51285@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51285-submit@debbugs.gnu.org id=B51285.163463842628015 (code B ref 51285); Tue, 19 Oct 2021 10:14:02 +0000 Received: (at 51285) by debbugs.gnu.org; 19 Oct 2021 10:13:46 +0000 Received: from localhost ([127.0.0.1]:49460 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcm7u-0007Hm-Ck for submit@debbugs.gnu.org; Tue, 19 Oct 2021 06:13:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33476) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcm7r-0007HE-4f for 51285@debbugs.gnu.org; Tue, 19 Oct 2021 06:13:43 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47974) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcm7l-0007VF-Uz; Tue, 19 Oct 2021 06:13:37 -0400 Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:59236 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcm7l-0005AA-Kz; Tue, 19 Oct 2021 06:13:37 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Tue, 19 Oct 2021 12:13:11 +0200 Message-Id: <20211019101311.10174-3-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211019101311.10174-1-ludo@gnu.org> References: <20211019101311.10174-1-ludo@gnu.org> MIME-Version: 1.0 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 * guix/scripts/shell.scm (hint-directory, hint-file, record-hint) (hint-given?): New procedures. (guix-shell): Record and probe the 'shell-check' hint. --- guix/scripts/shell.scm | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm index 4062e8155d..43e8484333 100644 --- a/guix/scripts/shell.scm +++ b/guix/scripts/shell.scm @@ -331,6 +331,30 @@ (define (profile-cached-gc-root file) (#f #f) (key (string-append (%profile-cache-directory) "/" key)))) + +;;; +;;; One-time hints. +;;; + +(define (hint-directory) + "Return the directory name where previously given hints are recorded." + (let ((directory (string-append (cache-directory #:ensure? #f) + "/hints"))) + (mkdir-p directory) + directory)) + +(define (hint-file hint) + "Return the name of the file that marks HINT as already printed." + (string-append (hint-directory) "/" (symbol->string hint))) + +(define (record-hint hint) + "Mark HINT as already given." + (close-port (open-file (hint-file hint) "w"))) + +(define (hint-given? hint) + "Return true if HINT was already given." + (file-exists? (hint-file hint))) + (define-command (guix-shell . args) (category development) @@ -348,7 +372,22 @@ (define* (entry-expiration file) (#f 0) ;FILE may have been deleted in the meantime (st (+ (stat:atime st) (* 60 60 24 7))))) - (let ((result (guix-environment* (parse-args args)))) + (define opts + (parse-args args)) + + (define interactive? + (not (assoc-ref opts 'exec))) + + (if (assoc-ref opts 'check?) + (record-hint 'shell-check) + (when (and interactive? + (not (hint-given? 'shell-check)) + (not (assoc-ref opts 'container?)) + (not (assoc-ref opts 'search-paths))) + (display-hint (G_ "Consider passing the @option{--check} option once +to make sure your shell does not clobber environment variables."))) ) + + (let ((result (guix-environment* opts))) (maybe-remove-expired-cache-entries (%profile-cache-directory) cache-entries #:entry-expiration entry-expiration)