zsh-users
 help / color / mirror / code / Atom feed
* io-redirect in function definitions
@ 2014-07-24 12:23 Roman Neuhauser
  0 siblings, 0 replies; only message in thread
From: Roman Neuhauser @ 2014-07-24 12:23 UTC (permalink / raw)
  To: zsh-users

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-07-24 12:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-24 12:23 io-redirect in function definitions Roman Neuhauser

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).