commit: 06cc72cc97b1c4f4c6a5c9301b5c562ecb9f04c4
parent 4585f387e2fde87a7cfbf56dfc9b9d6defcad175
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 17 Jan 2025 12:37:46 +0100
cmd/touch: use `return 1` instead of exit()
Diffstat:
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/cmd/touch.c b/cmd/touch.c
@@ -14,7 +14,6 @@
#include <fcntl.h> /* open */
#include <stdbool.h> /* bool */
#include <stdio.h> /* perror */
-#include <stdlib.h> /* exit, EXIT_FAILURE */
#include <string.h> /* strrchr, strlen */
#include <sys/stat.h> /* futimens, stat, utimensat */
#include <time.h> /* mktime */
@@ -164,7 +163,7 @@ main(int argc, char *argv[])
if(errstr != NULL)
{
fprintf(stderr, "touch: error: opt_t_parse(\"%s\", …): %s\n", optarg, errstr);
- exit(EXIT_FAILURE);
+ return 1;
}
break;
case 'd':
@@ -185,12 +184,12 @@ main(int argc, char *argv[])
if(errstr != NULL)
{
fprintf(stderr, "touch: error: iso_parse(\"%s\", …): %s\n", optarg, errstr);
- exit(EXIT_FAILURE);
+ return 1;
}
if(s == NULL)
{
fprintf(stderr, "touch: error: iso_parse(\"%s\", …) returned NULL\n", optarg);
- exit(EXIT_FAILURE);
+ return 1;
}
target.tv_sec = mktime_tz(&iso_res);
@@ -198,7 +197,7 @@ main(int argc, char *argv[])
if(target.tv_sec == (time_t)-1)
{
fprintf(stderr, "touch: error: mktime: %s\n", strerror(errno));
- exit(EXIT_FAILURE);
+ return 1;
}
errno = 0;
break;