Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Apply a patch from sergot++ with rm_rf

  • Loading branch information...
commit 5be31709a5d9b1a5c731cc8c479a5397b105369c 1 parent 11b0193
@tadzik authored
Showing with 13 additions and 3 deletions.
  1. +8 −2 lib/Shell/Command.pm
  2. +5 −1 t/02-shell-command.t
View
10 lib/Shell/Command.pm
@@ -1,4 +1,5 @@
module Shell::Command;
+use File::Find;
sub cat(*@files) is export {
for @files -> $f {
@@ -17,12 +18,17 @@ sub eqtime($source, $dest) is export {
sub rm_f(*@files) is export {
for @files -> $f {
- unlink $f if $f.IO ~~ :e;
+ unlink $f if $f.IO.e;
}
}
sub rm_rf(*@files) is export {
- ???
+ for @files -> $path {
+ for find(dir => $path).map({ .Str }).reverse -> $f {
+ $f.IO.d ?? rmdir($f) !! unlink($f);
+ }
+ rmdir $path;
+ }
}
sub touch(*@files) is export {
View
6 t/02-shell-command.t
@@ -1,7 +1,7 @@
use v6;
use Test;
use Shell::Command;
-plan 2;
+plan 3;
mkpath 't/dupa/foo/bar';
ok ('t/dupa/foo'.IO ~~ :d), 'mkpath, 1/2';
@@ -9,3 +9,7 @@ ok ('t/dupa/foo/bar'.IO ~~ :d), 'mkpath, 1/2';
rmdir 't/dupa/foo/bar';
rmdir 't/dupa/foo';
rmdir 't/dupa/';
+
+mkpath 't/a/b/c';
+rm_rf('t/a');
+ok !('t/a'.IO.d), 'rm_rf';
Please sign in to comment.
Something went wrong with that request. Please try again.