summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-11-27 17:04:55 +0100
committerFlorian Pritz <bluewind@xssn.at>2010-11-27 17:04:55 +0100
commitf13cd5fd1d45a12136ef25710f0a789f1bab2104 (patch)
tree1604ef478bbe20f7a425dfaf4c8b870ff73ead24
parentff5699c9b3e7bb83ba26467077b8d5b9f1e95cb6 (diff)
downloadbin-f13cd5fd1d45a12136ef25710f0a789f1bab2104.tar.gz
bin-f13cd5fd1d45a12136ef25710f0a789f1bab2104.tar.xz
restore.pl: fix restoration of /home/flo/bin
Signed-off-by: Florian Pritz <bluewind@xssn.at>
-rwxr-xr-xrestore.pl10
1 files changed, 7 insertions, 3 deletions
diff --git a/restore.pl b/restore.pl
index 63c89ff..3d00026 100755
--- a/restore.pl
+++ b/restore.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#----------------------------------------------------
-# Version: 0.1.1
+# Version: 0.1.2
# Author: Florian "Bluewind" Pritz <flo@xssn.at>
#
# Licensed under WTFPL v2
@@ -11,7 +11,7 @@
use warnings;
use strict;
use File::Basename;
-use Cwd;
+use Cwd qw(abs_path cwd);
use DateTime;
use File::Copy::Recursive qw(rcopy);
use File::Find;
@@ -27,9 +27,12 @@ if (@ARGV == 0) {
exit 0;
}
+my $startdir = cwd();
+
for my $filename (@ARGV) {
+ chdir $startdir;
my @filelist;
- my $file = Cwd::abs_path($filename);
+ my $file = abs_path($filename);
my $lastmodtime = 0;
for my $key (keys %mapping) {
@@ -69,6 +72,7 @@ for my $filename (@ARGV) {
print "\e[0;34mEnter ID to restore (Enter to skip): \e[0m";
my $id = <STDIN>;
chomp $id;
+ chdir "/";
next unless (exists ($filelist[$id]));
remove_tree $file if -d $file;
# need mtime preservation