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.

Newline produces wild results

See original GitHub issue

Using 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:

image

Actual behavior

Everything is colored after a newline. Exit escape sequence is never honored. screen shot 2019-02-04 at 5 11 30 pm

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.

screen shot 2019-02-04 at 5 14 26 pm ^ from version 0.6.1

We recently upgraded from version 0.5.7 and did not have this issue.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
DarrienGcommented, Feb 7, 2019

Thanks - we’ll give it a shot at our next maintenance cycle and report back.

0reactions
DarrienGcommented, May 2, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

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