question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please help to reset BOLD formatting for xTerm colors in bash script

See original GitHub issue

I run a script that has some primitive formatting. After executing the script, the entire next output becomes bold (but not green). It doesn’t happen in a normal terminal. How to completely reset all formatting after some commands?

Test environment

  • Jenkins Version: 2.150.2
  • AnsiColor Version: 0.6.1
  • Hostsystem: Ubuntu 16.04.4 LTS

Expected behavior

After closing ansiColor('xterm') { ... } all further formatting should be reset to normal.

Actual behavior

Everything is bold after ansiColor is finished its work.

image

Steps to reproduce the behavior

pipeline {
    agent { label 'worker' }
    stages {
        stage('colors') {
            steps {
                script {
                    ansiColor('xterm') {
                        writeFile file: 'script.sh', text: '''#!/usr/bin/env bash

RED="\\e[31m"
GREEN="\\e[32m"
BOLD="\\e[1m"
NORMAL="\\e[0m"

printf "${GREEN}${BOLD}"
printf "All updated ...\\n"
printf "${NORMAL}"
'''
                        sh '''
cat script.sh && chmod +x script.sh
'''
                        sh './script.sh'
                    }
                    println 'Why am I so bold?'
                }
            }
        }
    }
}

UP: The same happens if the plugin used inside options section.

options {
        ansiColor('xterm')
    }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kivagant-bacommented, Mar 7, 2019

Ok, let’s close this. If someone find the same problem and can isolate it, maybe he will reopen this or create a new ticket.

Thank you!

1reaction
kivagant-bacommented, Mar 7, 2019

then using chef-solo in the terminal means that all subsequent terminal output would be colored, right

No, locally it works fine. Only in Jenkins everything is colored after some of receipts executed on ec2 instances using chef-solo. I don’t know when and why it happens.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In an xterm, can I turn off bold or underline without resetting ...
The ${c_underline} escape sequence doesn't affect the color of the text; it only turns underlining on. ${c_nounderline} only turns underlining off.
Read more >
FLOZz' MISC » bash:tip_colors_and_formatting
Bash tips: Colors and formatting (ANSI/VT100 Control sequences) ... please help. ... To correctly reset either bold or dim to normal on xterm, ......
Read more >
bold text when using 256 colors - terminal - Unix StackExchange
"Boldness" is set separately from "foreground color", but it is not supported by Mutt. All you can do in Mutt is select a...
Read more >
BASH Shell Change The Color of Shell Prompt on Linux or UNIX
This page explains how to set up or change the color of bash shell prompt by editing $PS1 variable on a Linux, *BSD,...
Read more >
How can I change the colors of my xterm using Ansi escape ...
ANSI escape sequences consist of a sequence of characters beginning with the Escape character, character 27. The next character is often (though not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found