From ab870f61eec0e48c06ee1a5008e8aa0d77a0638e Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Wed, 2 Apr 2008 18:05:55 -0700 Subject: Add duplicate check to watchlink exclude file. --- scripts/vyatta-watchlink-exclude.pl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vyatta-watchlink-exclude.pl b/scripts/vyatta-watchlink-exclude.pl index 048946c..eb9d280 100755 --- a/scripts/vyatta-watchlink-exclude.pl +++ b/scripts/vyatta-watchlink-exclude.pl @@ -112,6 +112,18 @@ sub remove_exclude_line { return @new_lines; } +sub is_exclude_dup { + my ($new_line, @lines) = @_; + + my $frag = substr($new_line, 0, index($new_line, ' #')); + foreach my $line (@lines) { + if (substr($line, 0, index($line, ' #')) eq $frag) { + return 1; + } + } + return 0; +} + # # main @@ -148,7 +160,9 @@ if (defined $opt_id) { } if ($opt_action eq "add") { - push @lines, $new_line; + if (! is_exclude_dup($new_line, @lines)) { + push @lines, $new_line; + } } elsif (defined $opt_intf) { @lines = remove_exclude_line($new_line, @lines); } else { -- cgit v1.2.3