Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

io-redirect in function definitions



hello,

i just realized that zsh does not support redirections directly
attached to function bodies.  it does not complain, but does not
behave like sh:

> fname() compound-command[io-redirect ...]
> 
> When the function is declared, none of the expansions in wordexp
> shall be performed on the text in compound-command or io-redirect;
> all expansions shall be performed as normal each time the function
> is called.  Similarly, the optional io-redirect redirections and any
> variable assignments within compound-command shall be performed during
> the execution of the function itself, not the function definition.

i use this quite often, it's nice to be able to say

  foo()
  {
    echo this
    echo that
    echo other
  } >&2

instead of

  foo()
  {
    {
      echo this
      echo that
      echo other
    } >&2
  }

is that my only option?

BTW, syntax and semantics of the function definition statement could
use a bit of focus in the man pages, its documentation sprawls across
several places.

-- 
roman



Messages sorted by: Reverse Date, Date, Thread, Author