GNU bug report logs -
#51285
[PATCH 0/3] Add 'guix shell --check'
Previous Next
Reported by: Ludovic Courtès <ludo <at> gnu.org>
Date: Tue, 19 Oct 2021 10:05:02 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 51285 <at> debbugs.gnu.org (full text, mbox):
* 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
This bug report was last modified 3 years and 210 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.