From 69f17fe584d24a34b6d826780343819bdbcc3ccc Mon Sep 17 00:00:00 2001 From: Andinus Date: Thu, 8 Oct 2020 00:37:01 +0530 Subject: Get $backup_dir from config, format $mday with 2 leading zeros This will not work with previous configs. But that's fine because I'm the only one using this. --- leo.pl | 15 +++++++++------ share/config.pl | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/leo.pl b/leo.pl index fcf3bef..dcb8447 100755 --- a/leo.pl +++ b/leo.pl @@ -19,18 +19,20 @@ GetOptions( qw{ verbose encrypt sign delete help } ) or die "Error in command line arguments\n"; -my $ymd = ymd(); # YYYY-MM-DD. -my $backup_dir = "/tmp/backups/$ymd"; - -path($backup_dir)->mkpath; # Create backup directory. -my $prof; - # Config file for leo. my $config_file = $ENV{XDG_CONFIG_HOME} || "$ENV{HOME}/.config"; $config_file .= "/leo.pl"; require "$config_file"; +my $ymd = ymd(); # YYYY-MM-DD. +my $backup_dir = get_backup_dir() || "/tmp/backups"; +$backup_dir .= "/$ymd"; + +path($backup_dir)->mkpath; # Create backup directory. +my $prof; + + my %profile = get_profile(); my $gpg_fingerprint = get_gpg_fingerprint(); my $gpg_bin = get_gpg_bin(); @@ -145,5 +147,6 @@ sub ymd { my @months = qw( 01 02 03 04 05 06 07 08 09 10 11 12 ); my $month = $months[$mon]; + $mday = sprintf "%02d", $mday; return "$year-$month-$mday"; } diff --git a/share/config.pl b/share/config.pl index caee891..7d542f3 100644 --- a/share/config.pl +++ b/share/config.pl @@ -31,5 +31,6 @@ $profile{mozilla} = $profile{".mozilla"}; sub get_gpg_fingerprint { return $gpg_fingerprint; } sub get_profile { return %profile; } sub get_gpg_bin { return $gpg_bin; } +sub get_backup_dir { return "/tmp/backups" } 1; -- cgit 1.4.1-2-gfad0