diff options
author | Geoff Levand <geoff@infradead.org> | 2012-03-30 16:58:32 -0700 |
---|---|---|
committer | Geoff Levand <geoff@infradead.org> | 2012-03-30 18:08:57 -0700 |
commit | 52b9db95764fcdee9195113d7df225634a19c9f4 (patch) | |
tree | c1d649ca1316a816430728ce097acb1806f2fad9 /lib/system/system.c | |
parent | 45e253470f2cd7c6dfc38e7f533c62c454039873 (diff) | |
download | talos-petitboot-52b9db95764fcdee9195113d7df225634a19c9f4.tar.gz talos-petitboot-52b9db95764fcdee9195113d7df225634a19c9f4.zip |
Cleanup --dry-run option code
Signed-off-by: Geoff Levand <geoff@infradead.org>
Diffstat (limited to 'lib/system/system.c')
-rw-r--r-- | lib/system/system.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/system/system.c b/lib/system/system.c index 1b506d2..d77159d 100644 --- a/lib/system/system.c +++ b/lib/system/system.c @@ -103,9 +103,11 @@ int pb_rmdir_recursive(const char *base, const char *dir) /** * pb_run_cmd - Run the supplied command. * @cmd_argv: An argument list array for execv. + * @wait: Wait for the child process to complete before returning. + * @dry_run: Don't actually fork and exec. */ -int pb_run_cmd(const char *const *cmd_argv, int wait) +int pb_run_cmd(const char *const *cmd_argv, int wait, int dry_run) { #if defined(DEBUG) enum {do_debug = 1}; @@ -118,14 +120,19 @@ int pb_run_cmd(const char *const *cmd_argv, int wait) if (do_debug) { const char *const *p = cmd_argv; - pb_log("%s: ", __func__); + pb_log("%s: %s", __func__, (dry_run ? "(dry-run) " : "")); + while (*p) { pb_log("%s ", *p); p++; } pb_log("\n"); } else - pb_log("%s: %s\n", __func__, cmd_argv[0]); + pb_log("%s: %s%s\n", __func__, (dry_run ? "(dry-run) " : ""), + cmd_argv[0]); + + if (dry_run) + return 0; pid = fork(); |