host => undef,
identity => undef,
username => undef,
- 'sendmail-options' => '',
+ 'sendmail_options' => [''],
);
-# this is really janky, but because nullmailer doesn't properly handle
-# quotes, we must do it for it.
-my @fixed_argv;
-my $concatenate_to_last;
-my $p;
-for my $opt (@ARGV) {
- if ($concatenate_to_last) {
- $fixed_argv[-1].=' '.$opt;
- if (/$p/) {
- $concatenate_to_last = 0;
- }
- next;
- }
- if (/(['"])(.+)/ && $2 !~ /$1/) {
- $p = $1;
- $concatenate_to_last = 1;
- }
- push @fixed_argv,$opt;
-}
-@ARGV=@fixed_argv;
-
GetOptions(\%options,'identity|i=s','username|l=s','daemon|d', 'syslog|s',
- 'sendmail-options|o=s',
+ 'sendmail_options|sendmail-options|o=s@',
'help|h|?','man|m');
pod2usage() if $options{help};
push @ssh_arguments, '-i', $options{identity} if defined $options{identity};
push @ssh_arguments, '-l', $options{username} if defined $options{username};
-push @ssh_arguments, q(cat - | /usr/lib/sendmail ).$options{'sendmail-options'}.' '.join(' ',@recipients);
+push @ssh_arguments, q(cat - | /usr/lib/sendmail ).
+ join(' ',ref($options{sendmail_options})?@{$options{sendmail_options}}:($options{sendmail_options}//'')).
+ ' '.join(' ',@recipients);
qx(ping -q -c 3 $hostname 2>/dev/null);
if ($?) {
print STDERR "${0}: Failed: unable to ping $hostname\n";