From 546488b794abbc187fd070ccf54dd11842dec071 Mon Sep 17 00:00:00 2001 From: Andinus Date: Wed, 11 Nov 2020 15:15:46 +0530 Subject: Add option to print version, check for variable before splitting --- leo.pl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/leo.pl b/leo.pl index 92322db..1a12070 100755 --- a/leo.pl +++ b/leo.pl @@ -9,6 +9,8 @@ use Path::Tiny; use Config::Tiny; use Getopt::Long qw/ GetOptions /; +my $version = "leo v0.3.3"; + # Options. my %options = ( @@ -20,9 +22,12 @@ my %options = ( GetOptions( \%options, - qw{ verbose encrypt sign signify gzip help } + qw{ verbose encrypt sign signify gzip help version } ) or die "Error in command line arguments\n"; +# Print version. +print $version, "\n" and exit 0 if $options{version}; + # Configuration. my $config_file = $ENV{XDG_CONFIG_HOME} || "$ENV{HOME}/.config"; @@ -71,7 +76,11 @@ my $backup_dir = $options{backup_dir} || "/tmp/backups"; path($backup_dir)->mkpath; # Create backup directory. my $gpg_fingerprint = $options{gpg_fingerprint} || "`nil'"; -my @gpg_recipients = split / /, $options{gpg_recipients}; + +my @gpg_recipients; +@gpg_recipients = split / /, $options{gpg_recipients} + if $options{gpg_recipients}; + my $gpg_bin = $options{gpg_bin} || "gpg"; # Print help. @@ -243,6 +252,7 @@ Profile:}; print qq{ Compress with gzip(1) + --version [$version] --verbose --help }; -- cgit 1.4.1-2-gfad0