From nobody Mon Feb 9 07:26:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568015421; cv=none; d=zoho.com; s=zohoarc; b=bhGvKWevdKTwKE506Uba7WW/FwJJ/8SewUMaYWRcfZFJAALdVsFb0bWVaQxwo7eQbyqUw0bZJKMbbqVlUX9rsrAKyBdpYMgWZQydNrbRHQLp1pMP40dcCXSk8wgrg09aT8ZNVvklEZCcyTn4/nvq4ZzN4p2Ll9Tf9RhR90uc3JY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568015421; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=OWF3pW8BWFEO4R5MSZ5UqRQPPvI2oAl3Y0jFAZ62UaM=; b=P5C0cMb0vTXilpxm1cdlmss/QMO8x3coGS8WV80/9/AuEAuhSpp0l9ndwC19iibsT7qjdl5Vfdutlb3D4WIbiM5Ht+vU7OTQwQExCc6RiJIySusKRdZk27Kqy9rc8NCSusR2CMU4oTCrkcbQDeUNAJJ+Iq8jKc2k30G1M/WzdTU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568015421832232.99407059604948; Mon, 9 Sep 2019 00:50:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E2FB434CC; Mon, 9 Sep 2019 07:50:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B390D5D721; Mon, 9 Sep 2019 07:50:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 73FC0C593; Mon, 9 Sep 2019 07:50:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x897nnAF004858 for ; Mon, 9 Sep 2019 03:49:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 44EF25D6B7; Mon, 9 Sep 2019 07:49:49 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C33B05D6A7 for ; Mon, 9 Sep 2019 07:49:48 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 9 Sep 2019 09:49:41 +0200 Message-Id: <9c68f4a84f6553422c11b3b800d9c8e6e1730367.1568015323.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] configure: Colorize output X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 09 Sep 2019 07:50:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If we're running from a TTY we can put some colors around 'yes', 'no' and other messages. Shamelessly copied from Ruby source code and modified a bit to comply with syntax-check. https://github.com/ruby/ruby/commit/e4879592873abd4cd8aeed56f4cbaa360a3d3736 Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- m4/virt-colours.m4 | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 m4/virt-colours.m4 diff --git a/m4/virt-colours.m4 b/m4/virt-colours.m4 new file mode 100644 index 0000000000..251778f2ff --- /dev/null +++ b/m4/virt-colours.m4 @@ -0,0 +1,62 @@ +dnl Colourful configure +dnl +dnl Copyright (C) 2015 Nobuyoshi Nakada +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License, or (at your option) any later version. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library. If not, see +dnl . + +AC_DEFUN([_COLORIZE_RESULT_PREPARE], [ + msg_checking=3D msg_result_yes=3D msg_result_no=3D msg_result_other=3D= msg_reset=3D + AS_IF([test -t 1], [ + msg_begin=3D"`tput smso 2>/dev/null`" + AS_CASE(["$msg_begin"], ['=1B@<:@'*m], + [msg_begin=3D"`echo "$msg_begin" | sed ['s/[0-9]*m$//']`" + msg_checking=3D"${msg_begin}33m" + AS_IF([test ${TEST_COLORS:+set}], [ + msg_result_yes=3D[`expr ":$TEST_COLORS:" : ".*:pass=3D\([^:]*\):"`] + msg_result_no=3D[`expr ":$TEST_COLORS:" : ".*:fail=3D\([^:]*\):"`] + msg_result_other=3D[`expr ":$TEST_COLORS:" : ".*:skip=3D\([^:]*\):"`] + ]) + msg_result_yes=3D"${msg_begin}${msg_result_yes:-32;1}m" + msg_result_no=3D"${msg_begin}${msg_result_no:-31;1}m" + msg_result_other=3D"${msg_begin}${msg_result_other:-33;1}m" + msg_reset=3D"${msg_begin}m" + ]) + AS_UNSET(msg_begin) + ]) + AS_REQUIRE_SHELL_FN([colorize_result], + [AS_FUNCTION_DESCRIBE([colorize_result], [MSG], [Colorize result])], + [AS_CASE(["$[]1"], + [yes], [AS_ECHO(["${msg_result_yes}$[]1${msg_reset}]")], + [no], [AS_ECHO(["${msg_result_no}$[]1${msg_reset}]")], + [AS_ECHO(["${msg_result_other}$[]1${msg_reset}]")])]) +]) + +AC_DEFUN([COLORIZE_RESULT], [AC_REQUIRE([_COLORIZE_RESULT_PREPARE])dnl + AS_LITERAL_IF([$1], + [m4_case([$1], + [yes], [AS_ECHO(["${msg_result_yes}$1${msg_reset}"])], + [no], [AS_ECHO(["${msg_result_no}$1${msg_reset}"])], + [AS_ECHO(["${msg_result_other}$1${msg_reset}"])])], + [colorize_result "$1"]) dnl +]) + +AC_DEFUN([AC_CHECKING],[dnl +AC_REQUIRE([_COLORIZE_RESULT_PREPARE])dnl +AS_MESSAGE([checking ${msg_checking}$1${msg_reset}...])]) + +AC_DEFUN([AC_MSG_RESULT], [dnl +{ _AS_ECHO_LOG([result: $1]) +COLORIZE_RESULT([$1]); dnl +}]) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list