From 74980b51156d2aec59e5fe46d8926292f75b98fc Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Tue, 22 Aug 2006 15:56:52 +0000 Subject: [PATCH] For PR797: Fix a bug in my last patch that botched file redirection by using explicit scoping of if statements. llvm-svn: 29815 --- lib/System/Unix/Program.inc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc index 97aa804b3ce..5961dae5ad0 100644 --- a/lib/System/Unix/Program.inc +++ b/lib/System/Unix/Program.inc @@ -133,22 +133,27 @@ Program::ExecuteAndWait(const Path& path, case 0: { // Redirect file descriptors... if (redirects) { - if (redirects[0]) - if (redirects[0]->isEmpty()) + if (redirects[0]) { + if (redirects[0]->isEmpty()) { if (RedirectFD("/dev/null",0,ErrMsg)) { return -1; } - else + } else { if (RedirectFD(redirects[0]->toString(), 0,ErrMsg)) { return -1; } - if (redirects[1]) - if (redirects[1]->isEmpty()) + } + } + if (redirects[1]) { + if (redirects[1]->isEmpty()) { if (RedirectFD("/dev/null",1,ErrMsg)) { return -1; } - else + } else { if (RedirectFD(redirects[1]->toString(),1,ErrMsg)) { return -1; } + } + } if (redirects[1] && redirects[2] && *(redirects[1]) != *(redirects[2])) { - if (redirects[2]->isEmpty()) + if (redirects[2]->isEmpty()) { if (RedirectFD("/dev/null",2,ErrMsg)) { return -1; } - else + } else { if (RedirectFD(redirects[2]->toString(), 2,ErrMsg)) { return -1; } + } } else if (-1 == dup2(1,2)) { MakeErrMsg(ErrMsg, "Can't redirect"); return -1;