[Cook] Toggling options

Jason Evans jasone at canonware.com
Tue Jun 10 05:11:57 EST 2003


On Mon, Jun 09, 2003 at 02:44:15PM -0400, Jody Hagins wrote:
> On Mon, 9 Jun 2003 11:26:46 -0400
> Jody Hagins <jody at atdesk.com> wrote:
> 
> > 
> > I have a function that does a lot of commands, but I want them silent.
> > 
> > So, I "set silent" at the beginning of the function.  However, I want
> > to make sure that the "silence" is the same when I leave the function
> > as it was when I entered (i.e., if it was silent when I entered I do
> > not want to set it to noisy).  Is there a way of querying the status
> > so that I can reset it back to what it was before I entered the
> > function?
> 
> 
> 
> Worse, I have this function
> 
> function test_silence =
> {
>   set silent;
>   echo "FOo";
>   set nosilent;
> }
> 
> 
> and commands still are not echoed after calling test_silence...
> 
> 
> 
> What am I doing wrong?

This should work:

function test_silence =
{
  echo "FOo" set silent;
}

Functions do not provide a scope for flags, so you will have to set flags
on a per-command-statement basis within a function.  Recipes do provide a
scope for flags though, so if this were a recipe body you were trying to
silence, it would look like:

recipe :
  set silent
{
  /* Body. */
}

Jason



More information about the Cook-users mailing list