Newline produces wild results
See original GitHub issueUsing a newline within an set of ansi escape codes horribly breaks output.
Test environment
-
Jenkins Version: 2.162
-
AnsiColor Version: 0.6.0 (but even wilder results on 0.6.1)
-
Hostsystem: CentOS 7 Slaves run jnlp slave
Expected behavior
Color formatted lines and only formatted lines.
Like so:

Actual behavior
Everything is colored after a newline. Exit escape sequence is never honored.

Steps to reproduce the behavior
Use a newline in a set of ansi escape sequences.
#!/usr/bin/env bash
green() { echo -e "\033[0;32m${1}\033[0m"; }
green "some number of stuff"
echo "i am the next string"
totalTests=10
green "\n$(basename $0) ran successfuly, tests were run."
echo -e "Hey"
echo -e "There"
In a shell running bash 4+, this colors correctly, but with ansicolor, everything below the newline is green and irreversibly colored.
Version 0.6.1 is affected even worse than this, and produces some very strange results.
^ from version 0.6.1
We recently upgraded from version 0.5.7 and did not have this issue.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How can I have a newline in a string in sh?
I'm aware of echo -e , but I'm looking for a solution that allows passing a string (which includes a newline) as an...
Read more >The Great Newline Schism - Coding Horror
The Great Newline Schism is something you need to be aware of. Make sure your tools can show you not just those pesky...
Read more >sgr0 not supported anymore · Issue #135 · jenkinsci/ansicolor- ...
configure any job; ensure that 'Color ANSI Console Output' is enabled; add a new build step: 'Execute shell' ... Newline produces wild results...
Read more >Removing all line breaks in a document
I was recently sent a 500 page document to edit. For some reason there are two line breaks between every single paragraph. These...
Read more >Sentence Types: Simple, Compound, Complex, and ...
Practice: Identify whether the sentences are simple, complex, compound or compound-complex. Please underline dependent clauses where it applies.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks - we’ll give it a shot at our next maintenance cycle and report back.
Apologies, I don’t work where I used to work at the same place anymore. I think some of my old coworkers may know.
@yhrenlee do you know if the Jenkins folks are still having trouble with ansicolor and escape sequences? I seem to remember this was fixed.