From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2366C433B4 for ; Sat, 15 May 2021 22:10:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B0EA61355 for ; Sat, 15 May 2021 22:10:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235168AbhEOWLb (ORCPT ); Sat, 15 May 2021 18:11:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232925AbhEOWL2 (ORCPT ); Sat, 15 May 2021 18:11:28 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 738DFC061573 for ; Sat, 15 May 2021 15:10:13 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id q7-20020a9d57870000b02902a5c2bd8c17so2414347oth.5 for ; Sat, 15 May 2021 15:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:subject:mime-version :content-transfer-encoding; bh=hvhS4H4QZi1218duXwaZeSXwjGh+fC8DhW/P8Upuy2E=; b=kRMUs9Lt8NOCBayAy0pn4SJuwpKFZpawzGZA6btTUhwGXlwzv1/Y/iXMjkUBqHRBc/ Dt/aNgY1MQHs/n1b4oG9rskq/1ug8MHeQTCY0qvPXvJfjKM606REsZOZ5M2ngYS+YzL1 DanFk1oltewKk4MQUN4XMv1X8w4w+VNoIZq1452btQZKOX9Kmxg2EKpI0q2tM0pVRDh0 2AhvljpYmInYs9R7pKjS8fvQyejdByDCY6cNJkeO9AyFaZqwBpQsIvHft6vwICgS6sks K+D7f80eEfyEtrKA5oSZXypswpioITIyFvNW8jJyJRrJlTP5uWdxZyogHz0jAEM3xnYi /1Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:message-id:subject:mime-version :content-transfer-encoding; bh=hvhS4H4QZi1218duXwaZeSXwjGh+fC8DhW/P8Upuy2E=; b=pazkju2jpoTEGAmPZbJN31G7m9s7k/hqRgBlYV8p8BKAZyKscBa5n9WrR08ZV0T1R+ n2FxsrDjxLsWljPGgYxii6ietpEE4JOU22JSm1QF0WBf5CylmH2VjYY6DVG5kwnE75Dq zlw+CCTczF+6/3SsEBBy5MsneUkXMJhfP3q7xjeSkpwasnHRoYB0z95oYVO3X3gHPo4O n5jeeq+4j5VpQzQhplMN7UvX5ZumzfVdKTs9tcckebedNpRxRUUeiS1cmJPTGbkSH6rn 9N8CO9zO2cYEM/n+xMhWv4THNX7arabdDrm8pvoOev/ydlu2fDStPPea2cpPSUoDK5UY WURw== X-Gm-Message-State: AOAM5335ZLTGR9ZP+AYM+KBtmse2532axSzdCb309LNMG4Uv0WuoRlDN PO2ONOpJ57QuvmHgKGmtZQIXCf9LRRKtPQ== X-Google-Smtp-Source: ABdhPJyRRN0m2Nt2xENyfmeREzFe58eMtahN2RBJU2DkVj2CA1o7QlFBV7YFY9Ne0cIfO996PZNZvA== X-Received: by 2002:a9d:6394:: with SMTP id w20mr44151472otk.174.1621116612429; Sat, 15 May 2021 15:10:12 -0700 (PDT) Received: from localhost (fixed-187-189-165-231.totalplay.net. [187.189.165.231]) by smtp.gmail.com with ESMTPSA id b6sm1925788oic.12.2021.05.15.15.10.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 May 2021 15:10:12 -0700 (PDT) Date: Sat, 15 May 2021 17:10:05 -0500 From: Felipe Contreras To: git@vger.kernel.org Message-ID: <60a046bd83001_f4b0f20861@natae.notmuch> Subject: Man pages have colors? A deep dive into groff Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi, While I was doing the investigagion for my GNU_ROFF patch [1], I checked different versions of all the tools (asciidoc, asciidoctor, docbook, and groff). When I tested my own compiled version of groff I noticed something weird: man pages have colors. This did not happen with the version shipped by Arch Linux. I did notice the output generated by docbook stylesheets showed \m[blue], but no color showed up. It turns out Arch Linux disables colors, and so does Debian, by disabling a feature called SGR. This happened about 10 years, and the rationale was that "it doesn't work correctly". To enable SGR on these distributions you need to do GROFF_SGR=1, but that is not documented anywhere. groff does check for a variable GROFF_NO_SGR, but it's the other way around: SGR is enabled unless that variable is set. There's other ways your distribution might be screwing up with groff (for example Arch Linux converts \' to ', which is not correct), so you might want to check your shipped configuration in: /usr/share/groff/site-tmac/man.local Unfortunately the colors in man pages leave a lot to be desired. Here is a simple trick I've been using to show some custom colors: man() { GROFF_NO_SGR=1 \ LESS_TERMCAP_md=$'\e[1;31m' \ LESS_TERMCAP_me=$'\e[0m' \ LESS_TERMCAP_us=$'\e[1;34m' \ LESS_TERMCAP_ue=$'\e[0m' \ LESS_TERMCAP_so=$'\e[1;35m' \ LESS_TERMCAP_se=$'\e[0m' \ command man "$@" } Hopefully some of you might find this useful. Cheers. [1] https://lore.kernel.org/git/20210515115653.922902-2-felipe.contreras@gmail.com/ -- Felipe Contreras