summaryrefslogtreecommitdiff
path: root/rm.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-08-02 21:41:51 -0400
committerJakob Kaivo <jkk@ung.org>2019-08-02 21:41:51 -0400
commitfe0c0688c3cdeeadc5c37f008cf3b8481162fb4f (patch)
treefa27b2e77827c1ba792a7f4e5f86f637d8dd398e /rm.c
parent25965a249435a3fda795422cc61caf161580d441 (diff)
only compile regex once; remove redundant return statement
Diffstat (limited to 'rm.c')
-rw-r--r--rm.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/rm.c b/rm.c
index e54793d..6d92815 100644
--- a/rm.c
+++ b/rm.c
@@ -64,6 +64,7 @@ static int rm_prompt(const char *p)
if (!compiled) {
char *yesexpr = nl_langinfo(YESEXPR);
regcomp(&yesre, yesexpr, REG_EXTENDED | REG_ICASE | REG_NOSUB);
+ compiled = 1;
}
if (regexec(&yesre, buf, 0, NULL, 0) == 0) {
@@ -80,10 +81,8 @@ int rm(const char *p, const struct stat *st, int typeflag, struct FTW *f)
if (st == NULL) {
fprintf(stderr, "rm: %s: unknown error\n", p);
retval = 1;
- return 0;
- }
- if (S_ISDIR(st->st_mode)) {
+ } else if (S_ISDIR(st->st_mode)) {
if (!recursive) {
fprintf(stderr, "rm: %s: %s\n", p, strerror(EISDIR));
retval = 1;