]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: cat: do not exit(1) on missing units if `--force`
authorIvan Shapovalov <intelfx@intelfx.name>
Wed, 17 Jul 2024 08:50:27 +0000 (10:50 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 5 Sep 2024 01:08:03 +0000 (10:08 +0900)
We are eating the error message if `--force` is set, so do not return
a non-zero exit code either.

src/systemctl/systemctl-edit.c

index b7bd3851fd0b9576b63b4b7e21f4aae652add34c..880bd4d742e39d660166c28eb66f32a31725c66c 100644 (file)
@@ -69,8 +69,9 @@ int verb_cat(int argc, char *argv[], void *userdata) {
                         return r;
                 if (r == 0) {
                         /* Skip units which have no on-disk counterpart, but propagate the error to the
-                         * user */
-                        rc = -ENOENT;
+                         * user (if --force is set, eat the error, just like unit_find_paths()) */
+                        if (!arg_force)
+                                rc = -ENOENT;
                         continue;
                 }