Skip to content

Commit

Permalink
Use //= or |= to init $device in configure_static_ip
Browse files Browse the repository at this point in the history
  • Loading branch information
Martchus committed Feb 26, 2024
1 parent d83b57a commit a141091
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/mm_network.pm
Expand Up @@ -62,7 +62,7 @@ sub configure_static_ip {

if ($is_nm) {
my $nm_id;
$device = '\S' unless defined $device;
$device //= '\S';
my $nm_list = script_output("nmcli -t -f DEVICE,NAME c | grep -v '^lo:' | grep -e '$device' | head -n1");
($device, $nm_id) = split(':', $nm_list);

Expand All @@ -75,7 +75,7 @@ sub configure_static_ip {
my $mac = $net_conf->{fixed}->{mac};

# Get default network adapter name
$device = script_output("grep $mac /sys/class/net/*/address |cut -d / -f 5") unless ($device);
$device |= script_output("grep $mac /sys/class/net/*/address |cut -d / -f 5");
record_info('set_ip', "Device: $device\nIP: $ip\nMTU: $mtu");

# check for duplicate IP
Expand Down

0 comments on commit a141091

Please sign in to comment.