summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a3b0079)
raw | patch | inline | side by side (parent: a3b0079)
author | Shawn O. Pearce <spearce@spearce.org> | |
Sun, 11 Nov 2007 07:29:37 +0000 (02:29 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 12 Nov 2007 01:09:55 +0000 (17:09 -0800) |
Some callers may wish to redirect stderr to /dev/null in some
contexts, such as if they are executing a command only to get
the exit status and don't want users to see whatever output it
may produce as a side-effect of computing that exit status.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
contexts, such as if they are executing a command only to get
the exit status and don't want users to see whatever output it
may produce as a side-effect of computing that exit status.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
run-command.c | patch | blob | history | |
run-command.h | patch | blob | history |
diff --git a/run-command.c b/run-command.c
index d99a6c4ea7c776bec717c9952f77db7fa9a69c21..476d00c2182e3af82a0cfe495c61c9df1eb44d26 100644 (file)
--- a/run-command.c
+++ b/run-command.c
cmd->close_out = 1;
}
- need_err = cmd->err < 0;
+ need_err = !cmd->no_stderr && cmd->err < 0;
if (need_err) {
if (pipe(fderr) < 0) {
if (need_in)
close(cmd->out);
}
- if (need_err) {
+ if (cmd->no_stderr)
+ dup_devnull(2);
+ else if (need_err) {
dup2(fderr[1], 2);
close_pair(fderr);
}
diff --git a/run-command.h b/run-command.h
index 94e1e9d516887d818f99f8f6d6b3ded3f3be6d6f..1fc781d7668468f9e74bd430b7569dc040440ba8 100644 (file)
--- a/run-command.h
+++ b/run-command.h
unsigned close_out:1;
unsigned no_stdin:1;
unsigned no_stdout:1;
+ unsigned no_stderr:1;
unsigned git_cmd:1; /* if this is to be git sub-command */
unsigned stdout_to_stderr:1;
};