Commit | Line | Data |
---|---|---|
9f68db38 | 1 | #!/usr/bin/perl |
2 | ||
3 | ($op = shift) || die "Usage: relink perlexpr [filenames]\n"; | |
4 | if (!@ARGV) { | |
5 | if (-t) { | |
6 | @ARGV = <*>; | |
7 | } | |
8 | else { | |
9 | @ARGV = <STDIN>; | |
10 | chop(@ARGV); | |
11 | } | |
12 | } | |
13 | for (@ARGV) { | |
14 | next unless -l; # symbolic link? | |
15 | $name = $_; | |
16 | $_ = readlink($_); | |
17 | $was = $_; | |
18 | eval $op; | |
19 | die $@ if $@; | |
20 | if ($was ne $_) { | |
21 | unlink($name); | |
22 | symlink($_, $name); | |
23 | } | |
24 | } |