From ce4480a291b65be98074c58f0da251793a425568 Mon Sep 17 00:00:00 2001 From: Samuele Tognini Date: Wed, 3 Sep 2025 11:31:46 +0200 Subject: [PATCH] Strip ANSI color from Linux ip output On latest Debian versions the command "Ip add show" outputs color chars on interface names. This patch strips them fixing garbage in keys of Rex Template vars. --- lib/Rex/Hardware/Network/Linux.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Rex/Hardware/Network/Linux.pm b/lib/Rex/Hardware/Network/Linux.pm index 6e1f286a3..2bde9e151 100644 --- a/lib/Rex/Hardware/Network/Linux.pm +++ b/lib/Rex/Hardware/Network/Linux.pm @@ -14,6 +14,7 @@ use Rex::Helper::Run; use Rex::Commands::Run; use Rex::Helper::Array; use Data::Dumper; +use Term::ANSIColor qw(colorstrip); sub get_bridge_devices { unless ( can_run("brctl") ) { @@ -141,6 +142,7 @@ sub _parse_ip { my $cur_dev; for my $line (@ip_lines) { + $line = colorstrip($line); if ( $line =~ m/^\d+:\s*([^\s]+):/ ) { my $new_dev = $1;