]> git.donarmstrong.com Git - bin.git/blobdiff - sshsendmail
allow sendmail options to be specified multiple times
[bin.git] / sshsendmail
index 047d9a869ae1385691ced590857d1cea71c70d26..866847024fd2bff170f589033e241ce189cfd0bc 100755 (executable)
@@ -79,32 +79,11 @@ my %options = (debug              => 0,
               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};
@@ -145,7 +124,9 @@ my @ssh_arguments = ($hostname);
 
 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";