X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=coreutils%2Ftouch.c;h=3fe8b64ad1d1446787023f868d07fcd4118194fa;hb=d7e2e127a93afe2a88922ef94fa00fe8db39d834;hp=ae4e689f18d9a18528c52fb55d4dd2cd31672c71;hpb=06af2165288cd6516b89001ec9e24992619230e0;p=oweals%2Fbusybox.git diff --git a/coreutils/touch.c b/coreutils/touch.c index ae4e689f1..3fe8b64ad 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c @@ -17,22 +17,18 @@ * Also, exiting on a failure was a bug. All args should be processed. */ -#include -#include -#include -#include -#include -#include -#include -#include "busybox.h" - -int touch_main(int argc, char **argv); +#include "libbb.h" + +/* This is a NOFORK applet. Be very careful! */ + +int touch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int touch_main(int argc, char **argv) { int fd; int status = EXIT_SUCCESS; - bool flags = (getopt32(argc, argv, "c") & 1); + int flags = getopt32(argv, "cf"); + flags &= 1; /* ignoring -f (BSD compat thingy) */ argv += optind; if (!*argv) { @@ -41,7 +37,7 @@ int touch_main(int argc, char **argv) do { if (utime(*argv, NULL)) { - if (errno == ENOENT) { /* no such file*/ + if (errno == ENOENT) { /* no such file */ if (flags) { /* Creation is disabled, so ignore. */ continue; } @@ -54,7 +50,7 @@ int touch_main(int argc, char **argv) } } status = EXIT_FAILURE; - bb_perror_msg("%s", *argv); + bb_simple_perror_msg(*argv); } } while (*++argv);