From d92552c3ea104e1b0b9116663d6c92428934d388 Mon Sep 17 00:00:00 2001 From: nia Date: Sat, 1 Jul 2023 10:51:35 +0000 Subject: [PATCH] tetris(6): Support the informal standard of allowing setting NO_COLOR in the environment to disable the use of color. (no-color.org) --- games/tetris/tetris.6 | 9 +++++++-- games/tetris/tetris.c | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/games/tetris/tetris.6 b/games/tetris/tetris.6 index 8b6ca563e499..32915f8c0967 100644 --- a/games/tetris/tetris.6 +++ b/games/tetris/tetris.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: tetris.6,v 1.17 2016/03/12 03:14:59 dholland Exp $ +.\" $NetBSD: tetris.6,v 1.18 2023/07/01 10:51:35 nia Exp $ .\" .\" Copyright (c) 1992, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)tetris.6 8.1 (Berkeley) 5/31/93 .\" -.Dd February 18, 2015 +.Dd July 1, 2023 .Dt TETRIS 6 .Os .Sh NAME @@ -146,6 +146,11 @@ name, score, and how many points were scored on what level. Scores which are the highest on a given level are marked with asterisks .Dq * . +.Sh ENVIRONMENT +.Nm +honors the informal standard +.Dv NO_COLOR . +When it is set in the environment, no color will be used. .Sh FILES .Bl -tag -width /var/games/tetris.scoresxx .It /var/games/tetris.scores diff --git a/games/tetris/tetris.c b/games/tetris/tetris.c index 286e7c455019..b8612c2c8fe3 100644 --- a/games/tetris/tetris.c +++ b/games/tetris/tetris.c @@ -1,4 +1,4 @@ -/* $NetBSD: tetris.c,v 1.33 2020/07/21 02:42:05 nia Exp $ */ +/* $NetBSD: tetris.c,v 1.34 2023/07/01 10:51:35 nia Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -135,6 +135,7 @@ main(int argc, char *argv[]) int level = 2; #define NUMKEYS 7 char key_write[NUMKEYS][10]; + char *nocolor_env; int ch, i, j; int fd; @@ -182,6 +183,11 @@ main(int argc, char *argv[]) if (argc) usage(); + nocolor_env = getenv("NO_COLOR"); + + if (nocolor_env != NULL && nocolor_env[0] != '\0') + nocolor = 1; + fallrate = 1000000 / level; for (i = 0; i <= (NUMKEYS-1); i++) {