From 933516d19db0039c30ecf0609f963c68f8fc952c Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 10 Jun 2008 14:53:41 -0700 Subject: Do chomp in accessor routine for sysfs Code is cleaner if the newline and cruft are stripped by get_sysfs_value. --- scripts/vyatta-show-interfaces.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) mode change 100644 => 100755 scripts/vyatta-show-interfaces.pl diff --git a/scripts/vyatta-show-interfaces.pl b/scripts/vyatta-show-interfaces.pl old mode 100644 new mode 100755 index e50c097..d9e74b2 --- a/scripts/vyatta-show-interfaces.pl +++ b/scripts/vyatta-show-interfaces.pl @@ -114,6 +114,7 @@ sub get_sysfs_value { or die "Can't open statistics file /sys/class/net/$intf/$name"; my $value = <$statf>; + chomp $value if defined $value; close $statf; return $value; } @@ -187,13 +188,11 @@ sub get_state_link { my $state; my $link = 'down'; my $flags = get_sysfs_value($intf, 'flags'); - chomp $flags; my $hex_flags = hex($flags); if ($hex_flags & 0x1) { # IFF_UP $state = 'up'; my $carrier = get_sysfs_value($intf, 'carrier'); - chomp $carrier; if ($carrier eq '1') { $link = "up"; } -- cgit v1.2.3