Make sure configdir exists before die if we can't write to a file in that dir..
This commit is contained in:
8
pcurse
8
pcurse
@ -7,7 +7,11 @@ use Data::Dumper;
|
||||
use lib '.';
|
||||
use pcurse;
|
||||
|
||||
my $logfile = $ENV{'HOME'}.'/.pcurse/lastrun.log';
|
||||
my $confdir = $ENV{'HOME'}.'/.pcurse/';
|
||||
|
||||
#Make sure ~/.pcurse exists
|
||||
system('mkdir','-p',$confdir) unless(-d $confdir);
|
||||
my $logfile = $confdir.'lastrun.log';
|
||||
open my $lf, '>', $logfile or die 'Cannot write to logfile '.$logfile.': '.$!;
|
||||
select STDOUT;
|
||||
$| = 1;
|
||||
@ -20,7 +24,7 @@ my @toupd;
|
||||
my %jobs;
|
||||
my $workers;
|
||||
my $opts = pcurse::parse_arguments;
|
||||
$opts->{'config'} = $ENV{'HOME'}.'/.pcurse/config.json' unless(defined($opts->{'config'}));
|
||||
$opts->{'config'} = $confdir.'config.json' unless(defined($opts->{'config'}));
|
||||
my $conf = pcurse::load_config($opts->{'config'});
|
||||
$conf = pcurse::check_config($conf);
|
||||
($ret,$msg) = pcurse::save_config($conf->{'config'},$conf);
|
||||
|
||||
Reference in New Issue
Block a user