Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
io-redirect in function definitions
- X-seq: zsh-users 18990
- From: Roman Neuhauser <neuhauser@xxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: io-redirect in function definitions
- Date: Thu, 24 Jul 2014 14:23:31 +0200
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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