summaryrefslogtreecommitdiff
path: root/guix/status.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-01-15 11:47:25 +0100
committerLudovic Courtès <ludo@gnu.org>2019-01-15 12:05:25 +0100
commit0c1bc5ecbe72e06bfa0eefc75848d75a1fed2d77 (patch)
treedf2c88b6c5bb2f290fdb89ffb0b0d6a3a42462cf /guix/status.scm
parent35225dc57996ebc7a5a55462e0e52d85239195d9 (diff)
status: Spin only on TTYs.
* guix/status.scm (isatty?*): New procedure. (spin!): Do nothing when port matches ISATTY?*. (color-output?): Use ISATTY?*.
Diffstat (limited to 'guix/status.scm')
-rw-r--r--guix/status.scm20
1 files changed, 13 insertions, 7 deletions
diff --git a/guix/status.scm b/guix/status.scm
index 2928733257..478c475f8c 100644
--- a/guix/status.scm
+++ b/guix/status.scm
@@ -27,6 +27,7 @@
#:select (nar-uri-abbreviation))
#:use-module (guix store)
#:use-module (guix derivations)
+ #:use-module (guix memoization)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-19)
@@ -229,22 +230,27 @@ build-log\" traces."
(and (current-store-protocol-version)
(>= (current-store-protocol-version) #x163)))
+(define isatty?*
+ (mlambdaq (port)
+ (isatty? port)))
+
(define spin!
(let ((steps (circular-list "\\" "|" "/" "-")))
(lambda (port)
"Display a spinner on PORT."
- (match steps
- ((first . rest)
- (set! steps rest)
- (display "\r\x1b[K" port)
- (display first port)
- (force-output port))))))
+ (when (isatty?* port)
+ (match steps
+ ((first . rest)
+ (set! steps rest)
+ (display "\r\x1b[K" port)
+ (display first port)
+ (force-output port)))))))
(define (color-output? port)
"Return true if we should write colored output to PORT."
(and (not (getenv "INSIDE_EMACS"))
(not (getenv "NO_COLOR"))
- (isatty? port)))
+ (isatty?* port)))
(define-syntax color-rules
(syntax-rules ()