deltree.pl 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env perl
  2. # deltree: recursively removes file and directory,
  3. # trying to handle permissions and other complications.
  4. # Copyright (C) 2013-2017 Free Software Foundation, Inc.
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. use strict;
  16. use warnings FATAL => 'all';
  17. use File::Path qw/rmtree/;
  18. my $exit_status = 0;
  19. local $SIG{__WARN__} = sub { warn "@_"; $exit_status = 1; };
  20. foreach my $path (@ARGV) {
  21. local $@ = undef;
  22. rmtree ($path);
  23. }
  24. exit $exit_status;
  25. # vim: ft=perl ts=4 sw=4 et