diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-07-27 18:11:06 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-07-27 18:11:06 +0300 |
commit | 9055a493226bcfd6f7689cd0b07fdba00f034c88 (patch) | |
tree | d449dab131237b26b15cafd8df0ae59884a05e8a /tpnotify | |
parent | b1f09164c228341ed71e9622aeafde88c5b12b9d (diff) | |
download | tpnotify-9055a493226bcfd6f7689cd0b07fdba00f034c88.tar.gz tpnotify-9055a493226bcfd6f7689cd0b07fdba00f034c88.tar.bz2 |
Merge the two read_mh_path implementations
Diffstat (limited to 'tpnotify')
-rwxr-xr-x | tpnotify | 47 |
1 files changed, 16 insertions, 31 deletions
@@ -254,15 +254,20 @@ sub expand_template { sub read_mh_path { - if (open(my $fd, '<', "$ENV{HOME}/.mh_profile")) { - my $prev; - while (<$fd>) { - chomp; - if (s/^\s+//) { - $prev .= ' ' . $_; - } else { - last if $prev =~ /^Path:/; - $prev = $_; + my $file = File::Spec->catfile($ENV{HOME}, '.mh_profile'); + if (-f $file) { + if (open(my $fd, '<', $file)) { + my $prev; + while (<$fd>) { + chomp; + if (s/^\s+//) { + $prev .= ' ' . $_; + } else { + last if $prev =~ /^Path:/; + $prev = $_; + } } + close $fd; + return $prev if $prev =~ s/^Path:\s+//; + } else { + err("can't open $file: $!", prefix => 'warning'); } - close $fd; - return $prev if $prev =~ s/^Path:\s+//; } @@ -340,22 +345,2 @@ sub mail_box_manager_refile { -sub read_mh_path { - my $file = File::Spec->catfile($ENV{HOME}, '.mh_profile'); - my $path; - if (-f $file) { - if (open(my $fd, '<', $file)) { - while (<$fd>) { - chomp; - if (s/Path:\s*(.+)/$1/) { - $path = $1; - last; - } - } - close $path; - } - } else { - err("can't open $file: $!", prefix => 'warning'); - } - return $path; -} - sub movemail_supported { |