/usr/lib/mutt/mailspell is in mutt 1.5.21-6.4ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #!/usr/bin/perl
#
# Wrapper to call ispell on mail messages, ignoring quoted portions
# and signatures.
# By Brendan O'Dea <bod@debian.org>, public domain.
# Usage: set ispell = /usr/lib/mutt/mailspell
#
use IO::File;
use POSIX 'tmpnam';
use File::Copy 'move';
$0 =~ s#.*/##;
my $ISPELL = 'ispell';
my $DIFF = 'diff';
my $ED = 'ed';
# make sure that we don't inherit SIGCHLD
$SIG{CHLD} = 'DEFAULT';
# ignore -x ispell option
shift if $ARGV[0] eq '-x';
die "Usage: $0 [-x] FILE\n" unless @ARGV == 1;
my $msg = $ARGV[0];
# create temporary files
my (%orig, %ed);
END {
unlink $ed{path} if $ed{path};
unlink $orig{path} if $orig{path};
}
foreach (\%orig, \%ed) {
$_->{path} = tmpnam;
$_->{fd} = IO::File->new($_->{path}, O_RDWR|O_CREAT|O_EXCL, 0600)
or die "$0: can't create $_->{path} ($!)";
}
while (<>) {
# stop at sigdashes
last if /^-- \n/;
# drop quoted text and attribution
$orig{fd}->print($_) unless /^>/ or /^On \w{3}, \w{3} \d{2}, \d{4} at \d/;
}
$orig{fd}->close;
my $pid = fork;
die "$0: can't fork ($!)\n" unless defined $pid;
unless ($pid) {
open STDOUT, '>&=' . $ed{fd}->fileno
or die "$0: can't dup stdout to ed script ($!)\n";
$ed{fd}->close;
exec $DIFF, '-e', $orig{path}, $msg;
die "$0: can't exec $DIFF ($!)\n";
}
die "$0: can't reap child ($!)\n" unless wait == $pid;
system $ISPELL, '-x', $orig{path}
and die "$0: problem with $ISPELL ($?)\n";
$ed{fd}->seek(0, SEEK_END);
$ed{fd}->print("w\nq\n");
$ed{fd}->seek(0, SEEK_SET);
open STDIN, '<&=' . $ed{fd}->fileno
or die "$0: can't dup stdin from ed script ($!)\n";
system $ED, '-s', $orig{path} and die "$0: problem with $ED ($?)\n";
move $orig{path}, $msg or die "$0: can't replace $msg ($!)\n";
delete $orig{path};
1;
|