From 95e3bf4e2d912ffc87889c72cff7119523bf081b Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Fri, 29 Mar 2024 06:09:20 -0700 Subject: [PATCH] gnulib-tool.py: Display specified modules in bold. * pygnulib/GLImport.py (GLImport.prepare): Detect terminals starting with 'xterm'. Change hexadecimal numbers to octal, matching gnulib-tool.sh. * pygnulib/GLTestDir.py (GLTestDir.execute): Likewise. --- ChangeLog | 8 ++++++++ pygnulib/GLImport.py | 8 ++++---- pygnulib/GLTestDir.py | 8 ++++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 84a33eecb7..c6ac9f13a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-03-29 Collin Funk + + gnulib-tool.py: Display specified modules in bold. + * pygnulib/GLImport.py (GLImport.prepare): Detect terminals starting + with 'xterm'. Change hexadecimal numbers to octal, matching + gnulib-tool.sh. + * pygnulib/GLTestDir.py (GLTestDir.execute): Likewise. + 2024-03-29 Bruno Haible gnulib-tool.py: Don't print Makefile.am edits that are already done. diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index afe751dbd3..84e1c08689 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -849,10 +849,10 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix if verbose >= 0: bold_on = '' bold_off = '' - term = os.getenv('TERM') - if term == 'xterm': - bold_on = '\x1b[1m' - bold_off = '\x1b[0m' + term = os.getenv('TERM', '') + if term.startswith('xterm') and os.isatty(1): + bold_on = '\033[1m' + bold_off = '\033[0m' print('Module list with included dependencies (indented):') for module in final_modules: if str(module) in self.config.getModules(): diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py index 57fbef7b06..e395090b83 100644 --- a/pygnulib/GLTestDir.py +++ b/pygnulib/GLTestDir.py @@ -260,10 +260,10 @@ class GLTestDir(object): if verbose >= 0: bold_on = '' bold_off = '' - term = os.getenv('TERM') - if term == 'xterm': - bold_on = '\x1b[1m' - bold_off = '\x1b[0m' + term = os.getenv('TERM', '') + if term.startswith('xterm') and os.isatty(1): + bold_on = '\033[1m' + bold_off = '\033[0m' print('Module list with included dependencies (indented):') specified_modules_set = { str(module) for module in specified_modules } -- 2.44.0