conf

conf - my dotfiles manager
git clone git://git.alex.balgavy.eu/conf.git
Log | Files | Refs | README | LICENSE

commit 88abd34016826fc13cbd8dbd87ffcf02622da0dc
parent 9735f78de18c42e2f8b7f8fc958f25261e80c1b8
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Sat,  1 May 2021 14:03:05 +0200

Only die on nonexistent source when actually operating on it

Diffstat:
Mconf | 29++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/conf b/conf @@ -112,14 +112,7 @@ sub ParseMapfile { # Otherwise, it's a one-off mapping (doesn't have related nested mappings below) else { - # If the source doesn't exist, can't map - if (not -e $src) { - Die("error in mapfile: $src does not exist (line $lineno)"); - } - # If it does, add it as a mapping - else { - $mappings{"$src"} = $dst; - } + $mappings{"$src"} = $dst; } } @@ -144,13 +137,7 @@ sub ParseMapfile { else { my $fullsrc = join("/", @nestdir)."/$src"; # If it doesn't exist, can't map - if (not -e $fullsrc) { - Die("error in mapfile: $fullsrc does not exist (line $lineno)"); - } - # Otherwise, add the mapping - else { - $mappings{"$fullsrc"} = $dst; - } + $mappings{"$fullsrc"} = $dst; } } } @@ -173,6 +160,10 @@ sub PrettyPrint { sub MakeLinkOp { my ($src, $dst) = @_; + if (not -e $src) { + Die("error in mapfile: $src does not exist"); + } + # If the destination exists if (-e $dst) { # If it's a link and points to the source, nothing to do here @@ -202,6 +193,10 @@ sub MakeLinkOp { sub RmLinkOp { my ($src, $dst) = @_; + if (not -e $src) { + Die("error in mapfile: $src does not exist"); + } + # If the destination doesn't exist, nothing to do here. if (! -e "$dst") { puts "$dst does not exist."; @@ -224,6 +219,10 @@ sub RmLinkOp { # Check whether a link points to the config file sub CheckLinkOp { my ($src, $dst) = @_; + if (not -e $src) { + Die("error in mapfile: $src does not exist"); + } + if (-e $dst) { if (-l $_[1] and realpath($_[1]) eq $DOTFILES."/".$_[0]) { puts "[ OK ] $src is linked at $dst.";