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.

65 lines
1.4 KiB

  1. #!/usr/bin/perl
  2. # $RCSfile: vanish,v $$Revision: 4.1 $$Date: 92/08/07 17:20:54 $
  3. sub it {
  4. if ($olddir ne '.') {
  5. chop($pwd = `pwd`) if $pwd eq '';
  6. (chdir $olddir) || die "Directory $olddir is not accesible";
  7. }
  8. if (!-d .deleted) {
  9. print `mkdir .deleted; chmod 775 .deleted`;
  10. die "You can't remove files from $olddir" if $?;
  11. }
  12. $filelist =~ s/ $//;
  13. $filelist =~ s/#/\\#/g;
  14. if ($filelist !~ /^[ \t]*$/) {
  15. open(lastcmd,'>.deleted/.lastcmd');
  16. print lastcmd $filelist,"\n";
  17. close(lastcmd);
  18. print `/bin/mv $startfiles$filelist .deleted$force`;
  19. }
  20. if ($olddir ne '.') {
  21. (chdir $pwd) || die "Can't get back to original directory $pwd: $!\n";
  22. }
  23. }
  24. while ($ARGV[0] =~ /^-/) {
  25. $_ = shift;
  26. /^-f/ && ($force = ' >/dev/null 2>&1');
  27. /^-i/ && ($interactive = 1);
  28. if (/^-+$/) {
  29. $startfiles = '- ';
  30. last;
  31. }
  32. }
  33. chop($pwd = `pwd`);
  34. while ($file = shift) {
  35. if ($file =~ s|^(.*)/||) {
  36. $dir = $1;
  37. }
  38. else {
  39. $dir = '.';
  40. }
  41. if ($interactive) {
  42. print "vanish: remove $dir/$file? ";
  43. next unless <stdin> =~ /^y/i;
  44. }
  45. if ($file eq '.deleted') {
  46. print stderr "To delete .deleted (the trashcan) use the 'empty' command.\n";
  47. next;
  48. }
  49. if ($dir ne $olddir) {
  50. do it() if $olddir;
  51. $olddir = $dir;
  52. }
  53. $filelist .= $file; $filelist .= ' ';
  54. }
  55. do it() if $olddir;