diff options
Diffstat (limited to 'rm.c')
-rw-r--r-- | rm.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -33,11 +33,21 @@ | |||
33 | 33 | ||
34 | static int recursiveFlag = FALSE; | 34 | static int recursiveFlag = FALSE; |
35 | static int forceFlag = FALSE; | 35 | static int forceFlag = FALSE; |
36 | #ifdef BB_FEATURE_RM_INTERACTIVE | ||
37 | static int interactiveFlag = FALSE; | ||
38 | #endif | ||
36 | static const char *srcName; | 39 | static const char *srcName; |
37 | 40 | ||
38 | 41 | ||
39 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) | 42 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) |
40 | { | 43 | { |
44 | #ifdef BB_FEATURE_RM_INTERACTIVE | ||
45 | if (interactiveFlag == TRUE) { | ||
46 | printf("rm: remove `%s'? ", fileName); | ||
47 | if (ask_confirmation() == 0) | ||
48 | return (TRUE); | ||
49 | } | ||
50 | #endif | ||
41 | if (unlink(fileName) < 0) { | 51 | if (unlink(fileName) < 0) { |
42 | perror_msg("%s", fileName); | 52 | perror_msg("%s", fileName); |
43 | return (FALSE); | 53 | return (FALSE); |
@@ -52,6 +62,13 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk) | |||
52 | perror_msg("%s", fileName); | 62 | perror_msg("%s", fileName); |
53 | return (FALSE); | 63 | return (FALSE); |
54 | } | 64 | } |
65 | #ifdef BB_FEATURE_RM_INTERACTIVE | ||
66 | if (interactiveFlag == TRUE) { | ||
67 | printf("rm: remove directory `%s'? ", fileName); | ||
68 | if (ask_confirmation() == 0) | ||
69 | return (TRUE); | ||
70 | } | ||
71 | #endif | ||
55 | if (rmdir(fileName) < 0) { | 72 | if (rmdir(fileName) < 0) { |
56 | perror_msg("%s", fileName); | 73 | perror_msg("%s", fileName); |
57 | return (FALSE); | 74 | return (FALSE); |
@@ -79,6 +96,14 @@ extern int rm_main(int argc, char **argv) | |||
79 | break; | 96 | break; |
80 | case 'f': | 97 | case 'f': |
81 | forceFlag = TRUE; | 98 | forceFlag = TRUE; |
99 | #ifdef BB_FEATURE_RM_INTERACTIVE | ||
100 | interactiveFlag = FALSE; | ||
101 | #endif | ||
102 | break; | ||
103 | case 'i': | ||
104 | #ifdef BB_FEATURE_RM_INTERACTIVE | ||
105 | interactiveFlag = TRUE; | ||
106 | #endif | ||
82 | break; | 107 | break; |
83 | case '-': | 108 | case '-': |
84 | stopIt = TRUE; | 109 | stopIt = TRUE; |