OSDN Git Service

Implement shred -u and switch to default y in defconfig.
authorRob Landley <rob@landley.net>
Thu, 12 Mar 2015 20:32:50 +0000 (15:32 -0500)
committerRob Landley <rob@landley.net>
Thu, 12 Mar 2015 20:32:50 +0000 (15:32 -0500)
toys/other/shred.c

index 07d62c3..64db5ed 100644 (file)
@@ -8,7 +8,7 @@ USE_SHRED(NEWTOY(shred, "<1zxus#<1n#<1o#<0f", TOYFLAG_USR|TOYFLAG_BIN))
 
 config SHRED
   bool "shred"
-  default n
+  default y
   help
     usage: shred [-fuz] [-n COUNT] [-s SIZE] FILE...
 
@@ -100,5 +100,7 @@ void shred_main(void)
       if (throw != writeall(fd, toybuf, throw)) perror_msg("%s");
       pos += throw;
     }
+    if (toys.optflags & FLAG_u)
+      if (unlink(*try)) perror_msg("unlink '%s'", *try);
   }
 }