From 9316f445b62fbe9f92f8bf41c8c3780cd323839b Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 2 Feb 2023 14:47:10 +0100 Subject: nixos-format-error: grok SGR and \r --- krebs/5pkgs/simple/nixos-format-error.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'krebs/5pkgs') diff --git a/krebs/5pkgs/simple/nixos-format-error.nix b/krebs/5pkgs/simple/nixos-format-error.nix index 9ba410bbe..a28f7245f 100644 --- a/krebs/5pkgs/simple/nixos-format-error.nix +++ b/krebs/5pkgs/simple/nixos-format-error.nix @@ -30,14 +30,14 @@ pkgs.writeGawkBin "nixos-format-error" '' } state == IDLE { - if ($0 == "building the system configuration...") { + if ($0 ~ /^building the system configuration\.\.\. ?$/) { state = ACTIVE } out() } state == ACTIVE { - if ($1 == "error:") { + if ($1 ~ /(\[[0-9;]+m)?error:(\[[0-9;]m)?/) { state = ERROR sub(/^/,"\x1b[31;1m"); sub(/$/,"\x1b[m") trace[trace_count++] = $0 @@ -57,6 +57,8 @@ pkgs.writeGawkBin "nixos-format-error" '' } state == ERROR { + sub(/ $/, "") + gsub(/\[[0-9;]*m/, "") if ($0 ~ /^\s*at /) { location = gensub(/^\s*at (.*):$/,"\\1","1") -- cgit v1.2.3