Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.2 KiB

  1. #!/usr/bin/perl
  2. 'di';
  3. 'ig00';
  4. #
  5. # $RCSfile: relink,v $$Revision: 4.1 $$Date: 92/08/07 17:20:29 $
  6. #
  7. # $Log: relink,v $
  8. ($op = shift) || die "Usage: relink perlexpr [filenames]\n";
  9. if (!@ARGV) {
  10. @ARGV = <STDIN>;
  11. chop(@ARGV);
  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. }
  25. ##############################################################################
  26. # These next few lines are legal in both Perl and nroff.
  27. .00; # finish .ig
  28. 'di \" finish diversion--previous line must be blank
  29. .nr nl 0-1 \" fake up transition to first page again
  30. .nr % 0 \" start at page 1
  31. ';<<'.ex'; #__END__ ############# From here on it's a standard manual page ############
  32. .TH RELINK 1 "July 30, 1990"
  33. .AT 3
  34. .SH LINK
  35. relink \- relinks multiple symbolic links
  36. .SH SYNOPSIS
  37. .B relink perlexpr [symlinknames]
  38. .SH DESCRIPTION
  39. .I Relink
  40. relinks the symbolic links given according to the rule specified as the
  41. first argument.
  42. The argument is a Perl expression which is expected to modify the $_
  43. string in Perl for at least some of the names specified.
  44. For each symbolic link named on the command line, the Perl expression
  45. will be executed on the contents of the symbolic link with that name.
  46. If a given symbolic link's contents is not modified by the expression,
  47. it will not be changed.
  48. If a name given on the command line is not a symbolic link, it will be ignored.
  49. If no names are given on the command line, names will be read
  50. via standard input.
  51. .PP
  52. For example, to relink all symbolic links in the current directory
  53. pointing to somewhere in X11R3 so that they point to X11R4, you might say
  54. .nf
  55. relink 's/X11R3/X11R4/' *
  56. .fi
  57. To change all occurences of links in the system from /usr/spool to /var/spool,
  58. you'd say
  59. .nf
  60. find / -type l -print | relink 's#/usr/spool#/var/spool#'
  61. .fi
  62. .SH ENVIRONMENT
  63. No environment variables are used.
  64. .SH FILES
  65. .SH AUTHOR
  66. Larry Wall
  67. .SH "SEE ALSO"
  68. ln(1)
  69. .br
  70. perl(1)
  71. .SH DIAGNOSTICS
  72. If you give an invalid Perl expression you'll get a syntax error.
  73. .SH BUGS
  74. .ex