cthon: Have colors script exit with the proper exit code

Otherwise, the script will always return success and pipelines using
cthon.zsh won't work properly

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
Anna Schumaker 2022-04-18 11:23:48 -04:00
parent b02e2ee03d
commit cbcc5ba269
1 changed files with 4 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import termcolor
colors = { "b" : "blue", "g" : "green", "s" : "cyan", "l" : "yellow" }
last = "white"
newline = False
status=0
text = ""
def print_text(color, attr=None):
@ -20,6 +21,7 @@ while c := sys.stdin.read(1):
text = "\n" + text if newline else text
newline = False
print_text("red", "bold")
status=1
elif match := re.match("^./server -([bgsl]) .*?\n$", text):
print_text(colors[match.group(1)], None)
elif match := re.match("^Waiting for '([bgsl])' to finish...", text):
@ -33,3 +35,5 @@ while c := sys.stdin.read(1):
if len(text) > 1:
print_text("white", "bold")
text = ""
sys.exit(status)