Skip to content

Commit b9b9f28

Browse files
authored
mail: add --version (#833)
* mail: add --version * Declare VERSION_MESSAGE() as done in other scripts which use getopts() * It is not necessary to print a splash message when the program starts * Printing os in version message is not required (English.pm was only used for $OSNAME which disappears in this patch) * tweak usage string * Add $Program name variable as done in other scripts * Prefix usage string with "usage:"
1 parent c7e68e5 commit b9b9f28

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

bin/mail

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,15 +633,18 @@ EDLOOP: {
633633
1;
634634
package main;
635635

636-
use English;
636+
use File::Basename qw(basename);
637637
use File::Temp;
638638
use Getopt::Std;
639+
639640
use vars qw($opt_f $opt_s $opt_c $opt_b $opt_v);
640641

641642
our $VERSION = '0.04';
642643
our $ROWS = 23; # Screen Dimensions. Yeah, this sucks.
643644
our $COLS = 80;
644645
our $BUFFERL = 2; # Lines needed for "fluff"
646+
647+
my $Program = basename($0);
645648
my $box;
646649

647650
my %commands=(
@@ -975,7 +978,6 @@ sub Interactive {
975978
my $current=1;
976979

977980
select STDOUT; $|=1;
978-
print "Mail [$VERSION Perl] [$OSNAME]\n"; # This is fluff.
979981
my $cmd = "Init";
980982

981983
CMDS: {
@@ -1037,9 +1039,14 @@ sub Batch {
10371039
$mailer->send($message);
10381040
}
10391041

1042+
sub VERSION_MESSAGE {
1043+
print "$Program version $VERSION\n";
1044+
exit;
1045+
}
1046+
10401047
getopts("f:s:c:b:v") || die <<USAGE;
1041-
$0 [-f mailbox]
1042-
$0 [-s subject] [-c cc-addrs] [-b bcc-addrs] to-addr [..toaddr..]
1048+
usage: $Program [-s subject] [-c cc-addrs] [-b bcc-addrs] to-addr [..toaddr..]
1049+
or: $Program [-f mailbox]
10431050
USAGE
10441051

10451052
if (@ARGV) { # Assume batch-mode

0 commit comments

Comments
 (0)