X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?p=bin.git;a=blobdiff_plain;f=desymlink;h=f3cf416d535538b98acc53d8c3c28232593f5ef4;hp=a1a40ee2c81302e7d163928c354120d049b7c75f;hb=c750295af1ae879b6aa974bd750cd101eb54fc12;hpb=88c7e302a60194f68bc1b6d20c1547b62e1436d3 diff --git a/desymlink b/desymlink old mode 100644 new mode 100755 index a1a40ee..f3cf416 --- a/desymlink +++ b/desymlink @@ -1,16 +1,17 @@ #! /usr/bin/perl -w use strict; +use File::Copy; for (@ARGV) { my $source = $_; next unless -l $source; - my $target = readlink $source or die "readlink: $!"; + my $target = readlink $source or die "readlink $source: $!"; my $trap = sub { unlink $source; symlink $target, $source; print "Caught a SIG$_[0]!\n"; exit; }; local ($SIG{HUP}, $SIG{INT}, $SIG{TERM}, $SIG{QUIT}, $SIG{__DIE__}) = ($trap, $trap, $trap, $trap, $trap); - unlink $source; - system '/bin/cp', $target, $source; + unlink $source or die "unlink $source: $!"; + copy $target, $source or die "copy $source to $target: $!"; }