[hackers] [sbase] rm: Don't stop if file doesn't exist || sin
commit b7fd961186d129d3824be227083c45035496a4b8
Author: sin <sin_AT_2f30.org>
Date: Sun Dec 21 11:26:16 2014 +0000
rm: Don't stop if file doesn't exist
diff --git a/fs.h b/fs.h
index 4d65766..69a650f 100644
--- a/fs.h
+++ b/fs.h
_AT_@ -11,4 +11,4 @@ extern int rm_fflag;
extern int rm_rflag;
int cp(const char *, const char *);
-void rm(const char *);
+int rm(const char *);
diff --git a/libutil/rm.c b/libutil/rm.c
index 7261b6f..b6a6fe3 100644
--- a/libutil/rm.c
+++ b/libutil/rm.c
_AT_@ -7,11 +7,14 @@
int rm_fflag = 0;
int rm_rflag = 0;
-void
+int
rm(const char *path)
{
if (rm_rflag)
recurse(path, rm);
- if (remove(path) < 0 && !rm_fflag)
- eprintf("remove %s:", path);
+ if (remove(path) < 0 && !rm_fflag) {
+ weprintf("remove %s:", path);
+ return -1;
+ }
+ return 0;
}
diff --git a/rm.c b/rm.c
index a27dcb4..b1705b0 100644
--- a/rm.c
+++ b/rm.c
_AT_@ -16,6 +16,8 @@ usage(void)
int
main(int argc, char *argv[])
{
+ int ret = 0;
+
ARGBEGIN {
case 'f':
rm_fflag = 1;
_AT_@ -36,7 +38,8 @@ main(int argc, char *argv[])
}
for (; argc > 0; argc--, argv++)
- rm(argv[0]);
+ if (rm(argv[0]) < 0)
+ ret = 1;
- return 0;
+ return ret;
}
Received on Sun Dec 21 2014 - 12:27:37 CET
This archive was generated by hypermail 2.3.0
: Sun Dec 21 2014 - 12:36:10 CET