From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id QJfGL16bbmHtuwAAgWs5BA (envelope-from ) for ; Tue, 19 Oct 2021 12:18:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id YJuXK16bbmGNTwAA1q6Kng (envelope-from ) for ; Tue, 19 Oct 2021 10:18:06 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F1EA0129B5 for ; Tue, 19 Oct 2021 12:18:05 +0200 (CEST) Received: from localhost ([::1]:57544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcmC4-0001E1-Kj for larch@yhetil.org; 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 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1634638686; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=OoY7J9/UQz7WMQWGAmIJ54XT8QuKbVQLX1W5c7Pz2zw=; b=isgkVisiUynHMh5mCBovRcnEJSUytzah5AsM9dvZNH5qCXDxXxt6M95yjV3mljdYdV4hdg IL69N7IlsNRBNuJBScUNYyCfH/HZ+sEBC76jP8HnpAi4reH94a7gvNw7gNZ37WSELjSjSs PcerYHMqv0QSYP8Wt+48MIANPomDLXZC4fiD3F34DlxcPrZrBPuuojdX3sUQ6Nrf9cQBKz qCjYMxbAnmpGuBCMpGvjgiGWs1lohD9JZ6i4cHCOWgvco6qF/csQR2zPk7hX3IRnAoXiAm UQN1AXoi/1ZadL9Wt8G5uL3be0g95xxkF/s6XJF4eEX4LHAXXxJrsY5/klxYPA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1634638686; a=rsa-sha256; cv=none; b=iTGfrC47QSoli2odxL2lTYzmB2/ZaRja1nIx4SdQlK+U6JRnQLJbWooqtrY2YYSWShJ7A8 VdR1XvgJuo4ND1jUmaBv1cOH4s6o4tSd0wwU320gS2FCQwoG5cKEeS7skajEV/P1fi9nQk SXWjTZnBg7/UdVmXvIEzIjI3u38DJ1Y6/SUiG0j0Co4aEqw2w+Q7AiN+51p0U+/6kVjEb+ ofSRuzaWlZrK0N8+r3Szqy8+wECdl8u3PevHAb8bvXu1xxX5TRAp6X3A/loi8UpPLo4bJx y4bYngRlNYLWPQQ6qJYym9kfUKyJHxK4snCUmsRV4FsKBvZzbCgAz8+EWRAXrw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 1.27 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: F1EA0129B5 X-Spam-Score: 1.27 X-Migadu-Scanner: scn1.migadu.com X-TUID: Lo1Te4lc2K+8 * 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) -- 2.33.0