From patchwork Wed Feb 16 18:28:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil X-Patchwork-Id: 37287 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 92CE127BBEA; Wed, 16 Feb 2022 20:14:50 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 28E1A27BBE9 for ; Wed, 16 Feb 2022 20:14:50 +0000 (GMT) Received: from localhost ([::1]:58666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKQhN-0004Ws-71 for patchwork@mira.cbaines.net; Wed, 16 Feb 2022 15:14:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKPU6-0000wf-ID for guix-patches@gnu.org; Wed, 16 Feb 2022 13:57:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:55568) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nKPU6-0005ug-8P for guix-patches@gnu.org; Wed, 16 Feb 2022 13:57:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nKPU6-0006P8-8k for guix-patches@gnu.org; Wed, 16 Feb 2022 13:57:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#54029] [PATCH] allow user to force color when not a tty Resent-From: Phil Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 16 Feb 2022 18:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54029 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54029@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164503777424556 (code B ref -1); Wed, 16 Feb 2022 18:57:02 +0000 Received: (at submit) by debbugs.gnu.org; 16 Feb 2022 18:56:14 +0000 Received: from localhost ([127.0.0.1]:49465 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nKPTJ-0006Nz-UH for submit@debbugs.gnu.org; Wed, 16 Feb 2022 13:56:14 -0500 Received: from lists.gnu.org ([209.51.188.17]:37188) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nKP2A-0005dO-Be for submit@debbugs.gnu.org; Wed, 16 Feb 2022 13:28:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKP2A-00081w-63 for guix-patches@gnu.org; Wed, 16 Feb 2022 13:28:10 -0500 Received: from [2a00:1450:4864:20::329] (port=45922 helo=mail-wm1-x329.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nKP28-0000qG-Fa for guix-patches@gnu.org; Wed, 16 Feb 2022 13:28:09 -0500 Received: by mail-wm1-x329.google.com with SMTP id az26-20020a05600c601a00b0037c078db59cso2261725wmb.4 for ; Wed, 16 Feb 2022 10:28:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beadling-co-uk.20210112.gappssmtp.com; s=20210112; h=user-agent:from:to:subject:message-id:date:mime-version; bh=3mrleFCQUki3qxvKAPv+GcMFozys9ISVmfjXBJnq9z4=; b=KR3iiFVa1rci2o2T+P9lw2/8GUVha431re6C4Mj/ZTfOGcMDDyLiVyFeDi35D5SGrA Xsq6jg+S9/RrgVNMhnBNbgZMrwg31nXDszii28Csh/sdeZ0I0MUJbvvpOB8RmeTQ/SJr tV1g/IRLGvzkcAo31tC1883/yMHvTyZpgca1Qth+ROpaBD++Jak2yhO/VYwLdD86qgK+ Mu2nln01CfeSTpYFNeGM1NFbenrHImZ+kmCEDX3ehFI2P4PT9lyQyiB8gs/uHtgAHdre QVREO1QSRHXJqE3q7Hf31DGPD4/Kpq2Blaq0Qc91EhTEH3ODdAKJ7gCAYVNIcDGstlsK DEDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:user-agent:from:to:subject:message-id:date :mime-version; bh=3mrleFCQUki3qxvKAPv+GcMFozys9ISVmfjXBJnq9z4=; b=C/i6a8UP9rmaoykBeQjEdUsG0QtTonkbiirzrdcWL4sZUfs7+f0t43ED4R6wQCvOVC pfb7Wu/EddBHWbc7jcdz1sAl7SH4FuKVNoAh1boPj69Lasg4EqpfizLDOBdLnFoN+Lw5 5UbA7c48sySjzbM40TWfosh6rMSQRlhwp8CI7R1/FSTdrtc/kkJWzmpkZ9BdgdAAnLDG HM04z8Id0/lXATF0MGQ9SvzXBDGBRTbzd9SrdjDpqRc0YKnVRbxcm2FxPR/VUhQc19PZ oP1ZCuysuGxRqJcGNdE2TmgRMmgFq79d4Fa1PeZeHW3MYLEX42k9aPkhI+CjlmnFlLx4 Z7aQ== X-Gm-Message-State: AOAM530EQF5bKhSDNxHUZIbz426OGg+XquWN3KrizbhJXYOEEvSYa0QB aDkJjrNiGc+INWCcc9OauM7V7peEMQGlPq3fovhAug== X-Google-Smtp-Source: ABdhPJzHo7KvJB+OmV/FKqzBr/gVbuFaDUIRF+3MhSTSrSzDlHJpwzCzVoI9xlX8b0+oI7blwfvBnw== X-Received: by 2002:a05:600c:1d20:b0:37b:b441:d8d7 with SMTP id l32-20020a05600c1d2000b0037bb441d8d7mr2804708wms.170.1645036084972; Wed, 16 Feb 2022 10:28:04 -0800 (PST) Received: from xps13 (host-92-17-247-131.as13285.net. [92.17.247.131]) by smtp.gmail.com with ESMTPSA id z5sm23504054wmp.10.2022.02.16.10.28.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 10:28:04 -0800 (PST) User-agent: mu4e 1.4.15; emacs 27.2 From: Phil Message-ID: <87wnhuekek.fsf@beadling.co.uk> Date: Wed, 16 Feb 2022 18:28:03 +0000 MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::329 (failed) Received-SPF: none client-ip=2a00:1450:4864:20::329; envelope-from=phil@beadling.co.uk; helo=mail-wm1-x329.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.978, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 16 Feb 2022 13:56:12 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Wed, 16 Feb 2022 15:13:57 -0500 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 Hi, At the moment there doesn't seem to be any way to request ANSI stdout/err from Guix if your output is not a tty. However when capturing Guix output for display inside a front-end for running jobs across many servers (eg Jenkins, Rundeck, etc) - these tools are often capable of rendering ANSI output captured from console tools like Guix. Other tools (eg py-test, flake8) often allow the user to explicitly force color output even when a tty is not detected. The attached patch is a trivial attempt at make such an option available in Guix too. I've done this in the least disruptive way possible, which is to introduce an new env var such that users of the NO_COLOR env var will get continuity of functionality. Cheers, Phil From 010be2b6d4b1ec865a686345116deb92570636e2 Mon Sep 17 00:00:00 2001 From: "Phil.Beadling" Date: Wed, 16 Feb 2022 17:40:32 +0000 Subject: [PATCH] allow user to force color when not a tty --- guix/colors.scm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/guix/colors.scm b/guix/colors.scm index 3031f54799..c57c139864 100644 --- a/guix/colors.scm +++ b/guix/colors.scm @@ -131,8 +131,9 @@ that subsequent output will not have any colors in effect." (define (color-output? port) "Return true if we should write colored output to PORT." - (and (not (getenv "NO_COLOR")) - (isatty?* port))) + (or (getenv "GUIX_COLOR_OUTPUT") + (and (not (getenv "NO_COLOR")) + (isatty?* port)))) (define (coloring-procedure color) "Return a procedure that applies COLOR to the given string." -- 2.25.1