Skip to content

Commit

Permalink
Merge pull request spack#53 from kgerheiser/bugfix/bash-escape-format…
Browse files Browse the repository at this point in the history
…ting

Revert failed attempt to fix bash prompt when using colors
  • Loading branch information
climbfuji authored Apr 20, 2022
2 parents b2d9c45 + de56722 commit d23d5a5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/spack/llnl/util/tty/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def __init__(self, color=True):
def escape(self, s):
"""Returns a TTY escape sequence for a color"""
if self.color:
return "\[\033[%sm\]" % s
return "\033[%sm" % s
else:
return ''

Expand Down Expand Up @@ -207,12 +207,12 @@ def colorize(string, **kwargs):

def clen(string):
"""Return the length of a string, excluding ansi color sequences."""
return len(re.sub(r'\[\033[^m]*m\]', '', string))
return len(re.sub(r'\033[^m]*m', '', string))


def cextra(string):
"""Length of extra color characters in a string"""
return len(''.join(re.findall(r'\[\033[^m]*m\]', string)))
return len(''.join(re.findall(r'\033[^m]*m', string)))


def cwrite(string, stream=None, color=None):
Expand Down

0 comments on commit d23d5a5

Please sign in to comment.