From 0e0ac0bf19cbb92f0b12777b7cf955fb95ab09e5 Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Sat, 23 Nov 2024 21:09:43 +0800 Subject: [PATCH 1/2] 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) --- bin/mail | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/mail b/bin/mail index 8c035c1e..4942acc8 100755 --- a/bin/mail +++ b/bin/mail @@ -633,7 +633,6 @@ EDLOOP: { 1; package main; -use English; use File::Temp; use Getopt::Std; use vars qw($opt_f $opt_s $opt_c $opt_b $opt_v); @@ -975,7 +974,6 @@ sub Interactive { my $current=1; select STDOUT; $|=1; - print "Mail [$VERSION Perl] [$OSNAME]\n"; # This is fluff. my $cmd = "Init"; CMDS: { @@ -1037,6 +1035,11 @@ sub Batch { $mailer->send($message); } +sub VERSION_MESSAGE { + print "$0 version $VERSION\n"; + exit; +} + getopts("f:s:c:b:v") || die < Date: Mon, 25 Nov 2024 07:42:09 +0800 Subject: [PATCH 2/2] tweak usage string * Add $Program name variable as done in other scripts * Prefix usage string with "usage:" --- bin/mail | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/mail b/bin/mail index 4942acc8..95a86ad7 100755 --- a/bin/mail +++ b/bin/mail @@ -633,14 +633,18 @@ EDLOOP: { 1; package main; +use File::Basename qw(basename); use File::Temp; use Getopt::Std; + use vars qw($opt_f $opt_s $opt_c $opt_b $opt_v); our $VERSION = '0.04'; our $ROWS = 23; # Screen Dimensions. Yeah, this sucks. our $COLS = 80; our $BUFFERL = 2; # Lines needed for "fluff" + +my $Program = basename($0); my $box; my %commands=( @@ -1036,13 +1040,13 @@ sub Batch { } sub VERSION_MESSAGE { - print "$0 version $VERSION\n"; + print "$Program version $VERSION\n"; exit; } getopts("f:s:c:b:v") || die <