|
From: | Matthew Woehlke |
Subject: | Re: redirection after braced block |
Date: | Mon, 05 Oct 2009 14:03:06 -0500 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.23) Gecko/20090825 Fedora/2.0.0.23-1.fc10 Thunderbird/2.0.0.23 Mnenhy/0.7.5.0 |
clemens fischer wrote:
Andreas Schwab wrote:clemens fischer writes:I have the following construct in a script: ... a number of commands { ... a number of commands } 2>&1 | ${prog_log} "${logfile}" It seems anything inside the braces is not seen by bash, and it doesn't show up in a "sh -x ..." trace, but ${prog_log} does. I had debug echo's at the start of the block, they aren't triggered.The trace goes to stderr, but you've just redirected it.yeah ok, but the commands really are not executed. I have an option dry-run in the script, which sets "prog_log=true". Then there are a bunch of verbose commands in the block, none of get touched.
This sort of construct seems to be working fine for me. Note that the contents of the block are executed in a subshell, and using 'true' as prog_log will suppress both stdout and stderr, as set up (though you might get a broken pipe error). So unless the commands in the block have side effects observable outside of the script, you won't know whether or not they execute.
-- Matthew Please do not quote my e-mail address unobfuscated in message bodies. -- Q: Why doesn't Fedora provides ponies? -- Benny Amorsen A: Because they're too big to fit in the bikeshed. -- Mat Booth
[Prev in Thread] | Current Thread | [Next in Thread] |