diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-07-13 18:19:04 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-07-15 13:10:39 +0200 |
commit | 17021368fc5b9b3800125414362e82daf43a785d (patch) | |
tree | 53377b5e93f402871ff10bad2df1e9ee8ac001c1 /src/shared | |
parent | bless-boot-generator: use DEFINE_MAIN_GENERATOR_FUNCTION() (diff) | |
download | systemd-17021368fc5b9b3800125414362e82daf43a785d.tar.xz systemd-17021368fc5b9b3800125414362e82daf43a785d.zip |
generators: accept one or three args, do not write to /tmp
Since the general generator logic was established in the rewrite in
07719a21b6425d378b36bb8d7f47ad5ec5296d28, generators would always write to /tmp
by default. I think this not a good default at all, because generators write a
bunch of files and would create a mess in /tmp. And for debugging, one
generally needs to remove all the files in the output directory, because
generators will complain in the output paths are already present. Thus the
approach of disabling console logging and writing many files to /tmp when
invoked with no arguments is not nice, so let's disallow operation with no
args.
But when debugging, one generally does not care about the separate output dirs
(most generators use only one). Thus the general pattern I use is something
like:
rm -rf /tmp/x && mkdir /tmp/x && build/some-generator /tmp/{x,x,x}
This commit allows only one directory to be specified and simplifies this to:
rm -rf /tmp/x && mkdir /tmp/x && build/some-generator /tmp/x
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/generator.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/shared/generator.h b/src/shared/generator.h index bd768daf49..1b4f36ac53 100644 --- a/src/shared/generator.h +++ b/src/shared/generator.h @@ -3,6 +3,7 @@ #include <stdio.h> +#include "macro.h" #include "main-func.h" int generator_open_unit_file( @@ -86,11 +87,11 @@ void log_setup_generator(void); _DEFINE_MAIN_FUNCTION( \ ({ \ log_setup_generator(); \ - if (argc > 1 && argc != 4) \ + if (!IN_SET(argc, 2, 4)) \ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), \ - "This program takes zero or three arguments."); \ + "This program takes one or three arguments."); \ }), \ - impl(argc > 1 ? argv[1] : "/tmp", \ - argc > 1 ? argv[2] : "/tmp", \ - argc > 1 ? argv[3] : "/tmp"), \ + impl(argv[1], \ + argv[argc == 4 ? 2 : 1], \ + argv[argc == 4 ? 3 : 1]), \ r < 0 ? EXIT_FAILURE : EXIT_SUCCESS) |