[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: redirection after braced block

From: Greg Wooledge
Subject: Re: redirection after braced block
Date: Mon, 5 Oct 2009 15:35:39 -0400
User-agent: Mutt/

On Mon, Oct 05, 2009 at 07:55:33PM +0200, clemens fischer wrote:
> >>   {
> >>       ... a number of commands
> >>   } 2>&1 | ${prog_log} "${logfile}"

> 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.

In case the other response wasn't clear enough: you've got a pipeline
here.  Each command in a pipeline gets executed in its own subshell,
which means variables that are set in any part of a pipeline do not
appear (are not set) after the pipeline terminates.

If you're having trouble debugging your script, and you want to be
absolutely sure whether the commands in the braces are executing, you
should use commands that affect the file system (touch, etc.).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]