summaryrefslogtreecommitdiffhomepage
path: root/coreutils/rm.c
diff options
context:
space:
mode:
authorMark Whitley <markw@lineo.com>2001-03-13 00:40:19 +0000
committerMark Whitley <markw@lineo.com>2001-03-13 00:40:19 +0000
commite0bf91d7c612619526772605890538f0c3e44c05 (patch)
tree468e0e8126f57b7be69f471ed3ac046a9f8fedb4 /coreutils/rm.c
parent53737c5421b2356ead7659249000daac7c1aea21 (diff)
Applied patch from Christophe Boyanique to add -i support to rm.
Diffstat (limited to 'coreutils/rm.c')
-rw-r--r--coreutils/rm.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/coreutils/rm.c b/coreutils/rm.c
index a84163272..6d92b5daa 100644
--- a/coreutils/rm.c
+++ b/coreutils/rm.c
@@ -33,11 +33,21 @@
static int recursiveFlag = FALSE;
static int forceFlag = FALSE;
+#ifdef BB_FEATURE_RM_INTERACTIVE
+ static int interactiveFlag = FALSE;
+#endif
static const char *srcName;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
+#ifdef BB_FEATURE_RM_INTERACTIVE
+ if (interactiveFlag == TRUE) {
+ printf("rm: remove `%s'? ", fileName);
+ if (ask_confirmation() == 0)
+ return (TRUE);
+ }
+#endif
if (unlink(fileName) < 0) {
perror_msg("%s", fileName);
return (FALSE);
@@ -52,6 +62,13 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
perror_msg("%s", fileName);
return (FALSE);
}
+#ifdef BB_FEATURE_RM_INTERACTIVE
+ if (interactiveFlag == TRUE) {
+ printf("rm: remove directory `%s'? ", fileName);
+ if (ask_confirmation() == 0)
+ return (TRUE);
+ }
+#endif
if (rmdir(fileName) < 0) {
perror_msg("%s", fileName);
return (FALSE);
@@ -79,6 +96,14 @@ extern int rm_main(int argc, char **argv)
break;
case 'f':
forceFlag = TRUE;
+#ifdef BB_FEATURE_RM_INTERACTIVE
+ interactiveFlag = FALSE;
+#endif
+ break;
+ case 'i':
+#ifdef BB_FEATURE_RM_INTERACTIVE
+ interactiveFlag = TRUE;
+#endif
break;
case '-':
stopIt = TRUE;