7 visymlinks - Bulk edit target of symlinks
11 visymlinks [<PATH> [<PATH> [...]]]
15 Open up your default editor (see sensible-editor(1)) to edit the targets of I<PATH> symlinks
16 given in command arguments.
17 If no I<PATH> given, all symlinks will be edited in the current working directory.
18 Once finished in the editor, changes the target of those symlinks which were edited.
19 Contrary to visymlinks(1)'s relative, vidir(1),
20 if a I<PATH> symlink is removed in the editor, it won't be removed from the filesystem.
24 Returns zero if everything went fine.
25 Returns the exit status of the editor if it was not zero (also skip changing symlinks).
26 Returns the error code of symlink(2) if any of such calls failed.
30 vidir(1) from moreutils, vifiles(1)
35 use File
::Temp qw
/tempfile/;
38 $0 =~ s/.*\/([^\/]+)$/$1/;
40 ($fh, $filename) = tempfile
( "visymlinks-XXXXXX", TMPDIR
=> 1 );
42 push @ARGV, glob '*' unless @ARGV;
47 printf {$fh} ("%s\t%s\n", $path, readlink $path) or croak
"$0: $filename: write: $!";
51 close $fh or croak
"$0: $filename: close: $!";
53 system "sensible-editor", $filename;
58 open my $fh, '<', $filename or "$0: $filename: open: $!";
62 my ($path, $new_target) = split /\t/;
63 if(-e
$path and !-l
$path)
65 warn "$0: $path: no longer a symlink!\n";
69 my $old_target = readlink $path;
70 if($old_target ne $new_target)
72 warn "$0: $path: old target: $old_target\n";
73 warn "$0: $path: new target: $new_target\n";
75 symlink $new_target, $path or croak
"$0: $path: symlink: $!";