From 3270aa106b583aa1a36bd74c745c557a83fb39c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BE=E5=9C=B0=20=E5=B8=8C=E7=95=99=E8=80=B6?= <65301509+KiruyaMomochi@users.noreply.github.com> Date: Thu, 10 Mar 2022 02:07:07 +0900 Subject: [PATCH] Hide package repository count when redirecting stdout (#29402) --- lib/spack/spack/cmd/repo.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/cmd/repo.py b/lib/spack/spack/cmd/repo.py index a2e1d84e93..5fd6ba463e 100644 --- a/lib/spack/spack/cmd/repo.py +++ b/lib/spack/spack/cmd/repo.py @@ -6,6 +6,7 @@ from __future__ import print_function import os +import sys import llnl.util.tty as tty @@ -142,9 +143,10 @@ def repo_list(args): except spack.repo.RepoError: continue - msg = "%d package repositor" % len(repos) - msg += "y." if len(repos) == 1 else "ies." - tty.msg(msg) + if sys.stdout.isatty(): + msg = "%d package repositor" % len(repos) + msg += "y." if len(repos) == 1 else "ies." + tty.msg(msg) if not repos: return